Tuesday, 5 August 2014

MATLAB code for DSB-SC modulation

fc=167000;
fm=fc/100;
fs=100*fc;
t=0:1/fs:4/fm;
xc=cos(2*pi*fc*t);
xm1=2*cos(1000*pi*t)-sin(1500*pi*t);
xm2=1.5*cos(2000*pi*t);
xm=xm1+xm2;
figure(1)
subplot(3,1,1),plot(t,xm1);
title('mesaage signal 1');
xlabel('time (sec)');
ylabel('amplitude');
subplot(3,1,2),plot(t,xm2);
title('message signal 2');
xlabel('time (sec)');
ylabel('amplitude');
subplot(3,1,3),plot(t,xm);
title('total message signal');
xlabel('time (sec)');
ylabel('amplitude')
% DSB-SC MODULATION
z1= xm.*xc;
figure(2)
subplot(2,1,1),plot(t,z1);
title('DSB-SC MODULATION IN TIME DAOMAIN');
xlabel('time (sec)');
ylabel('amplitude');
l1=length(z1);
f=linspace(-fs/2,fs/2,l1);
Z1=fftshift(fft(z1,l1)/l1);
subplot(2,1,2),plot(f,abs(Z1));
title('DSB SC MODULATION IN FREQUENCY DOMAIN');
xlabel('frequency(hz)');
ylabel('amplitude');
demodulation
s1=z1.*xc;
S1=fftshift(fft(s1,length(s1))/length(s1));
figure(3)
plot(f,abs(S1));
title(' demodulated signal IN FREQUENCY DOMAIN before filtring');
xlabel('frequency(hz)');
ylabel('amplitude');

For information about DSB-SC modulation:
http://en.wikipedia.org/wiki/Double-sideband_suppressed-carrier_transmission