Matlab Code For CT
1)Amplitude Modulation
clear all;close all;clc;
fc=5000;
fs=30000;
N=5000;
Ts=1/fs;
t=(0:Ts:(N+Ts)-Ts);
fm=500;
m=cos(2*pi*fm*t);
mu=0.75;
[f1 m]=T2f(t,m);
[f2 c]=T2f(t,c);
s=(1+mu*m)*c;
[f3 s]=T2f(t,s);
figure();
subplot(3,2,1);
plot(t,m/max(m),'black','linewidth',1.5);
axis([0 0.005 -1.2 1.2]);
xlabel('time(seconds)');
ylabel('amplitude');
title('500hz message signal');
grid on;
subplot(3,2,2);
plot(fs,abs(m/max(m)),'r','linewidth',2);
axis([-8000 8000 -0.001 1.2]);
xlabel('frequencey');
ylabel('magnitude');
title('specturm of message signal');
grid on;
subplot(3,2,3);
plot(t,c/max(c),'b','linewidth',1.5);
axis([0 0.005 -1.2 1.2]);
xlabel('time(seconds)');
ylabel('amplitude');
title('20000hz carrier signal');
grid on;
subplot(3,2,4);
plot(fs,abs(c/max(c)),'m','linewidth',2);
axis([-8000 8000 -0.01 1.2]);
ctitle('specturm of carrier signal');
grid on;
subplot(3,2,5);
plot(t,rear(s/max(m)),'r','linewidth',1.5);
axis([00.005 -1.2 1.2]);
title('AM signal');
xlabel('time(seconds)');
ylabel('amplitude');
grid on;
subplot(3,2,6);
plot(f3,abs(s/max(s)),'b','linewidth',2);
grid on;
axis([-8000 8000 -0.02 1.2]);
xlabel('frequencey');
ylabel('magnitude');
title('spectrum of AM')
2)DSB
close all
clear all
clc
t=0:0.000001:0.001;
vm=1;
vc=1;
fm=2000;
fc=50000;
mt=vm*sin(2*pi*fm*t);
subplot(4,1,1);
plot(t,mt);
ct=vc*sin(2*pi*fc*t);
subplot(4,1,2);
plot(t,ct);
subplot(4,1,3);
st=mt.*ct;
hold on;
plot(t,st);
plot(t,mt,'r:');
plot(t,-mt,'r:');
r=st.*ct;
[b a]=butter(1,0.01);
mr=filter(b,a,r);
subplot(4,1,4);
plot(t,mr);
3)SSB
close all
clear all
clc
fs=8000;
fm=20;
fc=50;
Am=1;
Ac=1;
t=[0:0.1*fs]/fs;
subplot(5,1,1);
m1=Am*cos(2*pi*fm*t);
plot(t,m1);
title('message signal');
m2=Am*sin(2*pi*fm*t);
subplot(5,1,2);
c1=Ac*cos(2*pi*fc*t);
plot(t,c1);
title('carrier signal');
c2=Ac*sin(2*pi*fc*t)
subplot(5,1,3);
%Susb=0.5*Am*cos(2*pi*fm*t)*Ac*cos(2*pi*fc*t);
Susb=0.5*m1.*c1-0.5*m2.*c2;
plot(t,Susb);
title('SSB-SC signal with USB');
subplot(5,1,4);
S1sb=0.5*m1.*c1+0.5*m2.*c2;
plot(t,S1sb);
title('SSB-SC signal with LSB');
r=Susb.*c1;
subplot(5,1,5);
[b a]=butter(1,0.0001);
mr=filter(b,a,r);
plot(t,mr);
title('demodulated output');
Comments :
Post a Comment