Pulse Amplitude Modulation Using Matlab with Waveforms

By
Advertisement
 %PAM
 clc;
 clear all;
 close all;
 fc=100;
 fm=fc/10;
 fs=100*fc;
 t=0:1/fs:4/fm;
 mt=cos(2*pi*fm*t);
 ct=0.5*square(2*pi*fc*t)+0.5;
 st=mt.*ct;
 tt=[ ];
 %single sided PAM
 for i=1:length(st);
 if st(i)==0;
     tt=[tt,st(i)];
 else
     tt=[tt,st(i)+2];
 end
 end
 figure(1)
 subplot(4,1,1);
 plot(t,mt);
 title('message signal');
 xlabel('timeperiod');
 ylabel('amplitude');
 subplot(4,1,2);
 plot(t,ct);
 title('carrier signal');
 xlabel('timeperiod');
 ylabel('amplitude');
 subplot(4,1,3);
 plot(t,st);
 title('modulated signal of double side band');
 xlabel('timeperiod');
 ylabel('amplitude');
 subplot(4,1,4);
 plot(t,tt);
 title('PAM of single side band');
 xlabel('timeperiod');
 ylabel('amplitude');
 %demodulation
 dt=st.*ct;
 dt_frequency=fftshift(abs(fft(dt)));
filter=fir1(200,fm/fs,'low');
original_t_signal=conv(filter,dt);
original_f_signal=fftshift(abs(fft(original_t_signal)));
t1=0:1/(length(original_t_signal)-1):1;
f=-fs/2:fs/(length(original_f_signal)-1):fs/2;
figure(2)
 subplot(2,1,1);
 plot(t1,original_t_signal);
 title('time domain signal');
 xlabel('timeperiod');
 ylabel('amplitude');
 subplot(2,1,2);
 plot(f,original_f_signal);
 title('frequency domain signal');
 xlabel('frequency');
 ylabel('amplitude');
 axis([-50 50 0 2000])



2 comments:

  1. Very useful, good job

    ReplyDelete
  2. nice work men, i have a question why does t1 go up to 1 instead of 0.1

    ReplyDelete