dykow

lab3_ptk

Oct 25th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. clear; clc; clf; close;
  2. f1 = 1000;
  3. f2 = 1400;
  4. fc = 100000; % 220000
  5. Fs = 8 * fc;
  6. N = 3200;
  7. n = 0 : N-1;
  8. m = 1; % m = [0, 0.25, 0.5, 1, 1.2];
  9. %x = 5*sin(2*pi * (f1/Fs) * n) + 0*sin(2*pi * (f2/Fs) * n);
  10. A = linspace(0, 1, 800);
  11. B = linspace(-1, 0, 800);
  12. x = [A B A B];
  13.  
  14. x2n = x/max(abs(x));
  15. s = 10*(1 + m*x2n) .* cos(2*pi * fc/Fs * n);
  16. widmo = abs(fft(s));
  17.  
  18. subplot(311), plot(n/N * Fs ,x), grid;
  19. subplot(312), plot(n/N * Fs, s, '-x'), grid; % sygnal zmodulowany
  20. subplot(313), stem(n/N * Fs, widmo, '-x'), grid;
  21. axis([0 Fs/2 0 max(widmo)]);
  22.  
  23. figure;
  24.  
  25. % znak = (1 + sign(s)) / 2;
  26. % swypr = s .* znak;
  27. %
  28. % [B, A] = butter(1,5000 / (Fs/2));
  29. % u = filter(B, A, swypr);
  30. % subplot(311), plot(n, u), grid;
  31. % subplot(312), plot(n, x), grid;
  32. % subplot(313), plot(n, swypr), grid;
  33.  
  34.  
  35. %znak = (1 + sign(s)) / 2;
  36. %swypr = s .* znak;
  37. [B, A] = butter(4, 5000 / (Fs/2));
  38. v = s .* cos(2*pi * fc/Fs * n);
  39. u = filter(B, A, v);
  40. subplot(311), plot(n, u), grid;
  41. subplot(312), plot(n, x), grid;
  42. %subplot(313), plot(n, swypr), grid;
Advertisement
Add Comment
Please, Sign In to add comment