Advertisement
Stybyk

FSK-2

Nov 11th, 2015
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.43 KB | None | 0 0
  1. fs = 20;
  2. Ts = 1/fs
  3. L = 10- Ts;
  4. t = 0:Ts:L;
  5.  
  6.  
  7. f = zeros(1,200);
  8. f(1:100) = 2;
  9. f(101:200) = 5;
  10. signal = sin(2*pi*f.*t);
  11. N = length(signal);
  12.  
  13.  
  14. X_mags = abs(fftshift(fft(signal)));
  15. bin_vals = [0 : N-1];
  16. N_2 = ceil(N/2);
  17. fax_Hz = (bin_vals-N_2)*fs/N;
  18. subplot(2,1,1)
  19. plot(fax_Hz, X_mags)
  20. xlabel('Frequency (Hz)')
  21. ylabel('Magnitude');
  22. title('Double-sided Magnitude spectrum (Hertz)');
  23. axis tight
  24. subplot(2,1,2)
  25. plot(t,signal)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement