Advertisement
Narayan

FSK_Mod

Jan 21st, 2016
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.50 KB | None | 0 0
  1. clc
  2. clear all
  3. close all
  4.  
  5. %vm = input('Enter Amplitude (Message) = ');
  6. %vc = input('Enter Amplitude (Carrier) = ');
  7. %fM = input('Enter Message frequency = ');
  8. %fC = input('Enter Carrier frequency = ');
  9. %m = input('Enter Modulation Index = ');
  10.  
  11. message =[...
  12. 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0...
  13. 0 1 0 0 0 0 0 0 1 0 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 1 0 1 1 0 0 0 1...
  14. 1 0 0 1 0 0 0 0 1 0 0 0 0 1];
  15.  
  16. t = [0:1/(100*fC):10/fM]; %10000 samples
  17.  
  18. msg = vm*cos(2*pi*fM*t);
  19. subplot(4,1,1);
  20. plot(t,msg); %plotting message signal
  21. refresh;
  22. xlabel('Time [s]');
  23. ylabel('Amplitude [V]');
  24. title('Message Signal waveform');
  25. grid on;
  26. axis tight
  27.  
  28. carrier = vc*sin(2*pi*fC*t);
  29. subplot(4,1,2);
  30. plot(t,carrier); %plotting carrier signal
  31. xlabel('Time [s]');
  32. ylabel('Amplitude [V]');
  33. title('Carrier Signal waveform');
  34. grid on;
  35. axis tight
  36.  
  37. y = vc*cos(2*pi*fC*t+m*sin(2*pi*fM*t));
  38.  
  39. subplot(4,1,3);
  40. plot(t,y); %plotting FM (Frequency Modulated) signal
  41. xlabel('Time [s]');
  42. ylabel('Amplitude [V]');
  43. title('FM Signal waveform');
  44. grid on;
  45. axis tight
  46.  
  47.  
  48. N = length(y);
  49. fs = 100*fC; %50 mega samples per second
  50. fnyquist = fs/2; %Nyquist frequency
  51. X_mags = abs(fftshift(fft(y)));
  52. bin_vals = [0 : N-1];
  53. N_2 = ceil(N/2);
  54. fax_Hz = (bin_vals-N_2)*fs/N;
  55. subplot (4,1,4);
  56. plot(fax_Hz(N_2:52000), X_mags(N_2:52000), '-r', 'LineWidth', 2 )
  57. xlabel('Frequency [Hz]')
  58. ylabel('Magnitude');
  59. title('Double-sided Magnitude spectrum (Hertz)');
  60. grid on
  61. axis tight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement