Dsb3.m
Upload User: loeagle
Upload Date: 2013-03-02
Package Size: 1236k
Code Size: 2k
Development Platform:

Matlab

  1. % dsb1.m
  2. % Matlab demonstration script for DSB-AM modulation. The message signal
  3. % is +1 for 0 < t < t0/3, -2 for t0/3 < t < 2t0/3 and zero otherwise.
  4. echo on
  5. t0=.15;                               % signal duration
  6. ts=0.0005;                            % sampling interval
  7. fc=250;                               % carrier frequency
  8. snr=10;                               % SNR in dB (logarithmic)
  9. fs=1/ts;                              % sampling frequency
  10. t_long=20*t0;                         % extended signal duration 
  11. n0=floor(t_long/ts)+1;                % length of extended signal vector 
  12. n00=2^(ceil(log2(n0)));
  13. df=fs/n00;                             % frequency resolution
  14. t_long1=[0:ts:t_long];                % extended time vector
  15. f=[-fs/2+df:df:fs/2];                 % frequency vector 
  16. % message signal
  17. m=[ones(1,t0/(3*ts)),-2*ones(1,t0/(3*ts)),zeros(1,t0/(3*ts)+1)];
  18. m_long=[m,zeros(1,n0-length(m))];     % extended message signal 
  19. c_long=cos(2*pi*fc.*t_long1);         % extended carrier signal 
  20. u_long=m_long.*c_long;                % extended modulated signal
  21. du_long=u_long.*c_long;
  22. DU=fft(du_long,n00)/fs;
  23. M=fft(m_long,n00)/fs;                  % spectrum of the extended message signal 
  24. U=fft(u_long,n00)/fs;                   % spectrum of the extended modulated signal 
  25. pause   % Press any key to see a plots of the magnitude of the message and the
  26. % modulated signal in the frequency domain.
  27. subplot(2,1,1)
  28. plot(f,abs(fftshift(M)))
  29. xlabel('Frequency')
  30. title('Spectrum of the message signal')
  31. subplot(2,1,2)
  32. plot(f,abs(fftshift(U)))
  33. title('Spectrum of the modulated signal')
  34. xlabel('Frequency') 
  35. pause  % Press a key to see the modulated and modulated X carrier in freq. domain
  36. subplot(2,1,1)
  37. plot(f,abs(fftshift(U)))
  38. title('Modulated signal spectrum')
  39. xlabel('Frequency')
  40. subplot(2,1,2)
  41. plot(f,abs(fftshift(DU))) 
  42. title('Modulated signal X Carrier spectrum')
  43. xlabel('Frequency')