Advertisement
szymcio93

zad33

Oct 13th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. close all;
  2. clear all;
  3.  
  4. N=100;
  5. A = zeros(N, N);
  6.  
  7. for n=0:N-1
  8. for k=0:N-1
  9. if k == 0
  10. s = sqrt(1/N) ;
  11. else
  12. s = sqrt(2/N);
  13. end
  14. A(k+1, n+1) = s*cos(pi*k/N*(n+0.5));
  15. end
  16. end
  17.  
  18. S = A';
  19. fp = 1000;%czestotliwosc probkowania
  20. czas = N/fp;%czas przez jaki próbkujemy, #DEPRECATED#
  21. t=0:N-1;%ilość próbek
  22. t = t/fp;%przerobienie wektora na czas
  23.  
  24. f1 = 50;%52.5;
  25. f2 = 100;%102.5;
  26. f3 = 150;%152.5;
  27.  
  28. A1 = 50;
  29. A2 = 100;
  30. A3 = 150;
  31.  
  32. x = A1*sin(2*pi*f1*t) + A2*sin(2*pi*f2*t) + A3*sin(2*pi*f3*t);
  33. plot(x)
  34. pause
  35.  
  36. y=A*x';
  37.  
  38. figure()
  39. plot(1:N, abs(y), '-');%1:N, x);
  40. title('Sygnał w zależności od numeru próbki');
  41.  
  42. figure();
  43. plot((0:N-1)*fp/(2*N), abs(y), '-');
  44. title('Sygnał w zależności od nr próbki przeskalowanej na czestotliwosc');
  45.  
  46. % figure();
  47. % plot(t, y);
  48.  
  49. xs = S*y;
  50. blad_rekonstrukcji=max(abs(xs-x'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement