1
List of simulation experiments for Analog
Modulation Techniques
Roll no.-213ec5246
1)
Matlab programme:-
clc; clear all; close all;
ts=0.001; %sampling time
df=0.3; %desired frequeny resolution
fs=1/ts; %sampling frequency
t=0:0.001:2; %time interval
x=zeros(1,2001);
for i=1:2001 %defining msg signal
if(t(i)>=0.1 && t(i)<1)
x(i)=t(i);
elseif(t(i)>=1 && t(i)<2)
x(i)=-t(i)+2;
else
x(i)=0.1;
end;
end;
1
u=x.*sin(2*pi*25*t); %dsb modulated signal
subplot(221);
plot(t,u);
xlabel('time');ylabel('modulated signal');
title('modulated signal');
M=fft(u); % fourier transform of modulated signal
f=[0:1/2:(length(M)-1)/2]-fs/2; % frequency vector
subplot(222);
plot(f,fftshift(abs(M)));
xlabel('frequency');
title('spectrum of modulated signal');
hp = spectrum.periodogram('hamming');
hpopts = psdopts(hp,u);
hpsd1 = psd(hp,u,hpopts);% calculate psd of modulated signal
subplot(223);
plot(hpsd1)
power_modulated = avgpower(hpsd1); % calculate avg power of modulated signal
display(power_modulated);
hpsd2 = psd(hp,x,hpopts);% calculate psd of msg signal
subplot(224);
plot(hpsd2)
power_msg = avgpower(hpsd1);% power of msg signal
display(power_msg);
power_modulated =
1
0.3000
Q2)
Matlab program:-
clc; clear all; close all;
ts=0.001;%sampling time
df=0.3;%desired frequeny resolution
fs=1/ts;%sampling frequency
t=0:0.001:2;%time interval
x=zeros(1,2001);
for i=1:2001
if(t(i)>=0 && t(i)<1)
x(i)=t(i);
elseif(t(i)>=1 && t(i)<=2)
x(i)=-t(i)+2;
end;
end;
u=x.*sin(2*pi*25*t); %dsb modulated signal
subplot(221);
plot(t,u);
xlabel('time');ylabel('modulated signal');
title('modulated signal');
M=fft(u); % fourier transform of modulated signal
f=[0:1/2:(length(M)-1)/2]-fs/2; % frequency vector
subplot(222);
plot(f,fftshift(abs(M)));
xlabel('frequency');
title('spectrum of modulated signal');
hp = spectrum.periodogram('hamming');
hpopts = psdopts(hp,u);
hpsd1 = psd(hp,u,hpopts);% calculate psd of modulated signal
subplot(223);
plot(hpsd1)
power_modulated = avgpower(hpsd1); % calculate avg power of modulated signal
display(power_modulated);
hpsd2 = psd(hp,x,hpopts);% calculate psd of msg signal
subplot(224);
plot(hpsd2)
power_msg = avgpower(hpsd1);% power of msg signal
display(power_msg);
1
a)modulated signal
syms t
t1=(sinc(10*t)*sinc(10*t))^2;pw1=int(t1,t,-2,1);
pm=(1/p)*(pw1);
display('Q_b)power content of the modulated signal')
pow_u_mod=((ac^2)/2)*pm %b)power content of the modulated
signal
Warning: Explicit integral could not be
found. Q_b)power content of the modulated
signal
pow_u_mod =
int(sin(10*pi*t)^4/(10000*pi^4*t^4), t == -2..1)/8
clc;clear all;close all;
t=-30:0.01:30;p=4;ac=1;fc=100;
le=length(t);
1
m=zeros(1,le);
for i=1:le
if (t(i)>=-2 && t(i)<=2)
m(i)=m(i)+(sinc(10*t(i))*sinc(10*t(i)));
else
end
end
m(i)=m(i)+0;
3
plot(t,m,'r');axis([-3 3 -1.5 1.5]);grid on;title('Given i/p sig.');
c=ac*cos(2*pi*fc*t); %carrier u_mod=m.*c;
%a)Modulated sig figure,plot(t,u_mod);axis([-3 3 -1.5 1.5]);;grid
on;title('Modulated sig');
b)power content of modulated signal
syms t
t1=(sinc(10*t)*sinc(10*t))^2;pw1=int(t1,t,-2,1);
pm=(1/p)*(pw1);
3
display('Q_b)power content of the modulated signal')
pow_u_mod=((ac^2)/2)*pm %b)power content of the modulated signal
Warning: Explicit integral could not be found.
Q_b)power content of the modulated signal
pow_u_mod =
int(sin(10*pi*t)^4/(10000*pi^4*t^4), t == -2..1)/8
c)spectrum of the carrier and modulated
Fs = 1000;
tc = 0:1/Fs:1-(1/Fs);
% x = 14*cos(200*pi*t-pi/3);% x=2*cos(2*pi*100*t);
c=ac*cos(2*pi*fc*tc);
xdft = (1/length(c))*fft(c);
freq = -500:(Fs/length(c)):500-(Fs/length(c));
figure,plot(freq,abs(fftshift(xdft))); %spectrum of the carrier signal
title('spectrum of the carrier signal')
le=length(tc);
m=zeros(1,le);
for i=1:le
if (tc(i)>=-2 && tc(i)<=2)
m(i)=m(i)+(sinc(10*tc(i))*sinc(10*tc(i)));
else
end end
u_mod=m.*c;
m(i)=m(i)+0;
xdft = (1/length(u_mod))*fft(u_mod);
freq = -500:(Fs/length(u_mod)):500-(Fs/length(u_mod));
figure,plot(freq,abs(fftshift(xdft)));
title('spectrum of the modulated signal') %c)spectrum of the modulated s
4
d)Power spectral density PSD
carrier,modulated and message
Hs=spectrum.cov;
psd(Hs,c,'Fs',Fs); %% PSD of carrier
figure,psd(Hs,u_mod,'Fs',Fs);hold on; %% PSD of modulated signal
figure,psd(Hs,m,'Fs',Fs); %% PSD of msg
% peak amplitude is at f=100 Hz
5
1
1
3.5
a)USB Modulated
clc;clear all;close all;
t=-50:0.1:50;p=2;ac=1;fc=25;
le=length(t);
m=zeros(1,le);
for i=1:le
if (t(i)>=0 && t(i)<0.1)
m(i)=m(i)+0.1;
else if (t(i)>=0.1 && t(i)<1)
m(i)=m(i)+t(i);
else if (t(i)>=1 && t(i)<1.9)
m(i)=m(i)-t(i)+2;
else m(i)=m(i)+0.1;
end
end
end
end
m;
plot(t,m,'r');axis([0 2 0 1.5]);title('Given i/p sig.');
% t1 = (0:1/1023:1);
y = hilbert(m);
plot(t,real(y));axis([-5 5 -3 3]);grid on; hold on
plot(t,imag(y),':');axis([-5 5 -3 3])
% axis([0 0.05 -1.1 2]);
legend('Real-Part-i/p','Imag-Part-hilb-trans','location','best');
im=imag(y);
c=ac*cos(2*pi*fc*t);c1=ac*sin(2*pi*fc*t); %carrier
u_mod=(ac/2)*((m.*c)-(im.*c1)); %a)USB Modulated sig
figure,plot(t,u_mod);axis([-5 5 -3 3]);grid on;title('Modulated sig');
3
4
b)power content of the modulated
syms t
t1=0.1;pw1=int(t1,t,0,0.1);
t2=t^2;pw2=int(t2,t,0.1,1);
t3=(-t+2)^2;pw3=int(t3,t,1,1.9);
t4=0.1;pw4=int(t4,t,1.9,2);
pm=(1/p)*(pw1+pw2+pw3+pw4);
display('Q_b)power content of the USB modulated signal')
pow_u_mod=((ac^2)/4)*pm %b)power content of the modulated
Q_b)power content of the USB modulated signal
pow_u_mod =
343/4000
c)spectrum of the carrier ,unmodulated
modulated
Fs = 1000;
tc = 0:1/Fs:1-(1/Fs);
% x = 14*cos(200*pi*t-pi/3);% x=2*cos(2*pi*100*t);
c=ac*cos(2*pi*fc*tc);
xdft = (1/length(c))*fft(c);
freq = -500:(Fs/length(c)):500-(Fs/length(c));
figure,plot(freq,abs(fftshift(xdft)));grid on; %spectrum of the carri
title('spectrum of the carrier signal')
le=length(tc);
m1=zeros(1,le);
for i=1:le
if (tc(i)>=0 && tc(i)<0.1)
m1(i)=m1(i)+0.1;
else if (tc(i)>=0.1 && tc(i)<1)
m1(i)=m1(i)+tc(i);
else if (tc(i)>=1 && tc(i)<1.9)
m1(i)=m1(i)-tc(i)+2;
else m1(i)=m1(i)+0.1;
end
end
end
end
m1;
xdft = (1/length(m1))*fft(m1);
freq = -500:(Fs/length(m1)):500-(Fs/length(m1));
figure,plot(freq,abs(fftshift(xdft)));grid on;
title('spectrum of the unmodulated signal') %spectrum of the unmodulat
y1 = hilbert(m1);
5
im=imag(y1);
c=ac*cos(2*pi*fc*tc);c1=ac*sin(2*pi*fc*tc);
u_mod=(ac/2)*((m1.*c)-(im.*c1));
xdft = (1/length(u_mod))*fft(u_mod);
freq = -500:(Fs/length(u_mod)):500-(Fs/length(u_mod));
figure,plot(freq,abs(fftshift(xdft)));grid on;
title('spectrum of the modulated signal') %c)spectrum of the modulated s
5
d)Power spectral density PSD
carrier,modulated and message
Hs=spectrum.cov;
psd(Hs,c,'Fs',Fs); %% PSD of carrier
figure,psd(Hs,u_mod,'Fs',Fs); %% PSD of modulated signal
figure,psd(Hs,m,'Fs',Fs); %% PSD of msg
% peak amplitude is at f=25hz
6
PROGRAM-3.8
a)Modulated
signal
clc;clear all;close all;
t=-50:0.1:50;p=2;ac=1;fc=25;
le=leng
th(t);
m=zeros
(1,le);
for
i=1:le
if (t(i)>=0 && t(i)<0.1)
m(i)=m(i)+0.1;
else if (t(i)>=0.1 && t(i)<1)
m(i)=m(i)+t(i);
else if (t(i)>=1 && t(i)<1.9)
m(i)=m(i)-t(i)+2;
else
m(i)=m(i)+0;
end
end
end
end
plot(t,m,'r');axis([0 2 0 1.5]);grid on;title('Given i/p sig.');
c=ac*cos(2*pi*fc*t); %carrier u_mod=m.*c;
%a)Modulated sig figure,plot(t,u_mod);axis([-5 5 -3 3]);grid
on;title('Modulated sig');
3
b)PWR in demod sig VS f(theta)
syms t f
t1=0.1;pw1=int(t1,t,0,0.1);
t2=t^2;pw2=int(t2,t,0.1,1);
t3=(-t+2)^2;pw3=int(t3,t,1,1.9);
t4=0.1;pw4=int(t4,t,1.9,2);
pm=(1/p)*(pw1+pw2+pw3+pw4);
display('Q_b)power content of the demodulated signal')
ac=ac^2;pf=cos(f);
pow_u_mod=((ac*pf)^2)*pm %power content of the demodulated
pow_u_mod(f)=pow_u_mod;
p=0; f=0:0.01:pi/2;
p=[p,pow_u_mod(f)];
p=[p(2:length(p))];
figure,plot(f,p,'r');grid on;title('PWR in demod sig VS f') %b)PWR in demod sig
legend('0<=theta<=pi/2','location','Best')
q_b)power content of the demodulated signal
pow_u_mod =
(343*cos(f)^2)/1000
1
PROGRAM-3.9
a)Modulated
clc;clear all;close all;
t=-50:0.1:50;p=2;ac=1;fc=25;
le=length(t);
m=zeros(1,le);
for i=1:le
if (t(i)>=0 && t(i)<0.1)
m(i)=m(i)+0.1;
else if (t(i)>=0.1 && t(i)<1)
m(i)=m(i)+t(i);
else if (t(i)>=1 && t(i)<1.9)
m(i)=m(i)-t(i)+2;
else m(i)=m(i)+0.1;
end
end
end
end
plot(t,m,'r');axis([0 2 0 1.5]);
2
y = hilbert(m);
plot(t,real(y));axis([-5 5 -3 3]); hold on
plot(t,imag(y),':');axis([-5 5 -3 3]);grid on;title('Given i/p sig.');
legend('Real-Part-i/p','Imag-Part-hilb-trans','location','best');
im=imag(y);
max_amp=max(im);
c=ac*cos(2*pi*fc*t);c1=ac*sin(2*pi*fc*t); %carrier
u_mod=(ac/2)*((m.*c)-(im.*c1)); %a)USB Modulated sig
figure,plot(t,u_mod);axis([-5 5 -3 3]);grid on;title('Modulated sig');
syms t f
t1=0.1;pw1=int(t1,t,0,0.1);
t2=t^2;pw2=int(t2,t,0.1,1);
t3=(-t+2)^2;pw3=int(t3,t,1,1.9);
t4=0.1;pw4=int(t4,t,1.9,2);
pm=(1/p)*(pw1+pw2+pw3+pw4); %power content of the msg signal
display('power content of the demodulated signal')
pow_u_mod=((ac^2)/4)*pm ;
pf=cos(f);
pow_u_mod1=((pf)^2)*pow_u_mod;
pow_u_mod1(f)=pow_u_mod1
pwh=int((max_amp)^2,t,0,2);
p_hilb=(1/p)*pwh ; %power content of the hilbert trans.
display('power content of the hilbert trans. of msg signal')
pow_u_hmod=((ac^2)/4)*p_hilb;
pf1=sin(f);
pow_u_mod2=((pf1)^2)*pow_u_hmod;
pow_u_mod2(f)=pow_u_mod2
p_ussb=pow_u_mod1(f)-pow_u_mod2(f);
p_ussb(f)=p_ussb
power content of the demodulated signal
pow_u_mod1(f) =
(343*cos(f)^2)/4000
power content of the hilbert trans. of msg signal
pow_u_mod2(f) =
(4586806831851157*sin(f)^2)/72057594037927936
p_ussb(f) =
(343*cos(f)^2)/4000 - (4586806831851157*sin(f)^2)/72057594037927936
3
4
b)Demod. sig for
acd=(ac^2)/4;
u_demod1=acd*(m*pf);
u_demod2=acd*(im*pf1);
u_demod=(u_demod1)-(u_demod2);
u_demod(f)=u_demod;
u_demod(0);
p=0;p=[p,u_demod(0)];p=[p(2:length(p))];
t1=-50:0.1:50;
figure,plot(t1,p,'r');axis([-0.5 2.5 -1 1]);grid on;title('Demod signal for theta=
u_demod(30);
p1=0;p1=[p1,u_demod(30)];p1=[p1(2:length(p1))];
figure,plot(t1,p1,'r');axis([-0.5 2.5 -1 1]);grid on;title('Demod signal for theta
u_demod(45);
p2=0;p2=[p2,u_demod(45)];p2=[p2(2:length(p2))];
figure,plot(t1,p2,'r');axis([-0.5 2.5 -1 1]);grid on;title('Demod signal for theta
u_demod(60);
p3=0;p3=[p3,u_demod(60)];p3=[p3(2:length(p3))];
figure,plot(t1,p3,'r');axis([-0.5 2.5 -1 1]);grid on;title('Demod signal for theta
u_demod(90);
p4=0;p4=[p4,u_demod(90)];p4=[p4(2:length(p4))];
figure,plot(t1,p4,'r');axis([-0.5 2.5 -1 1]);grid on;title('Demod signal for thet