Advertisement
albert828

widmo amplitudowe, fazowe, przeciek, aliasing

Nov 23rd, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.87 KB | None | 0 0
  1. %widmo amplitudowe, fazowe, przeciek, aliasing
  2. %dla sumy dwoch sygnalow sinusoidalnych o częst f1 i f2
  3.  
  4.  
  5. clear all; clg; subplot(111);
  6.  
  7. fs = 2000;
  8. N = 1000;
  9. Ts = 1/fs;
  10. t = 0:Ts:(N-1)*Ts;
  11. f1 = 141;
  12. f2 = 380.5;
  13. A1 = 2;
  14. A2 = 1;
  15.  
  16.  
  17. x1 = A1*sin(2*pi*f1*t); %2 sin
  18. x2 = A2*sin(2*pi*f2*t); %1 sin
  19. x = x1+x2;  %sygnal
  20. x = x.*hanning(length(x))'; %sygnal okienkowany (Hanning)
  21.  
  22. subplot(3,1,1);
  23. plot(t, x); grid on;
  24. title('Sygnal');
  25. xlabel('Sekundy');
  26. ylabel('x(n)');
  27.  
  28. X = abs(fft(x)); %widmo amplitudowe
  29. deltaf = fs/N %rozdzielczosc widma
  30. disp(['Rozdzielczosc widma w Hz: ',num2str(deltaf)]);
  31.  
  32. f=0:deltaf:fs-deltaf; %wektor czestotliwosci
  33.  
  34. subplot(3,1,2);
  35. stem(f,X,'.');
  36. grid on;
  37.  
  38.  
  39. subplot(3,1,3);
  40. stem(f(1:250),X(1:250));
  41. grid on;
  42.  
  43. title(['widmo amplitudowe, rozdzielczosc widma =',num2str(deltaf),'Hz']);
  44. xlabel('czestotliwosc w Hz');
  45. ylabel('X(m)');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement