Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.79 KB | None | 0 0
  1. clear all;
  2. fp = 1000;  %czestotliwosc probkowania
  3. fs1 = 10;  %czestotliwosc sygnalu #1
  4. fs2 = 100;   %czestotliwosc sygnalu #2
  5. A = 1;      %amplituda sygnalu
  6. N = 500;   %liczba probek
  7. phi = pi/3; %przesuniecie fazowe
  8. t = 0:1/fp:(N-1)/fp;%wektor czasu
  9. % otrzymujemy wektory _x_ i _x1_
  10. x = A*sin(2*pi*fs1*t + phi);%nasz sygnal
  11. x1= A*sin(2*pi*fs2*t);%nasz sygnal
  12. f = 0: fp/N: fp - fp/N;
  13.  
  14. %%transformata Fouriera
  15. X = fft(x);
  16. X1 = fft(x1);
  17. X2 = fft(x1+x);
  18.  
  19. figure(1)
  20. y=x+x1; % suma sygnałów
  21. y1=y+0.3*randn(size(y));
  22. plot(t,y,t,y1)
  23.  
  24.  
  25. %%%wykres widma amplitudowego w dB
  26. figure(2)
  27. plot(f,abs(20*log10(abs(X2))))
  28. xlabel 'czestotliwosc [Hz]'
  29. title 'widmo amplitudowe sygnalu'
  30.  
  31. %%%
  32. faza = unwrap(angle(X));
  33. figure(3)
  34. plot(f,faza*180/pi)
  35. xlabel ''
  36. title 'wykres widma fazowego'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement