Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. clear all;
  2. close all;
  3. clc;
  4.  
  5. fs=1000; Ts=1/fs;
  6.  
  7. f1=20;
  8. DigFreq1=2*pi*f1/fs;
  9. f2=30;
  10. DigFreq2=2*pi*f2/fs;
  11. f3=40;
  12. DigFreq3=2*pi*f3/fs;
  13.  
  14. N=1500;
  15. n = 0:1:N-1;
  16. t_sample = (0: Ts : (N-1)*Ts);
  17.  
  18. x=3.*cos(DigFreq1.*n+0.2) + cos(DigFreq2.*n-0.3) + 2.*cos(DigFreq3.*n+2.4);
  19. figure; plot(t_sample, x)
  20.  
  21. X=fft(x);
  22. X_mag=abs(X);
  23. figure;
  24.  
  25. Fbin=0:1:N-1;
  26. plot((fs/N).*Fbin, X_mag/(N/2));
  27. xlim([0 fs/2])
  28. set(gca, 'FontSize', 16)
  29. xlabel('$f(Hz)$', 'Interpreter', 'LaTex', 'FontSize', 18);
  30. ylabel('$|X(\omega)|$', 'Interpreter', 'LaTex', 'FontSize', 18);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement