CMS Lab-4
CMS Lab-4
CMS Lab-4
Matlab Code :
clc;
clear;
fs = 8000;
fm=10;
fc = 100;
t=(0:0.2*fs)/fs;
Am = 1;
Ac = 1;
kf = input('Frequency Sensitivity(kf) = ');
Wm =2*pi*fm;
m = Am*cos(Wm*t);
subplot(2,2,1);
plot(t,m);
title('Message Input Signal');
xlabel('Time --->');
ylabel('Amplitude --->')
Wc= 2*pi*fc;
c = Ac*cos(Wc*t);
subplot(2,2,2);
plot(t,c);
title('Carrier Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
% Frequency Modulation
s_fm = Ac*cos(Wc*t+((2*pi*kf*Am)/Wm)*sin(Wm*t));
subplot(2,2,3);
plot(t,s_fm);
title('Frequency Modulated Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
% Frequency Demodulation ;
s = Ac*(Wc +
2*pi*kf*Am*cos(Wm*t)).*sin(Wc*t+((2*pi*kf*Am)/Wm)*sin(Wm*t)) ;
x = abs(hilbert(s));
y = x/(2*pi*kf) ;
subplot(2,2,4) ;
plot(t,y) ;
title('Frequency Demodulated Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
Q2. Generate the message signal from the PM
modulated signal.
Matlab Code :
clc;
clear;
fs = 8000;
fm=10;
fc = 200;
t=(0:0.2*fs)/fs;
Am = 1;
Ac = 1;
kp = input('Phase Sensitivity(kp) = ');
Wm =2*pi*fm;
m = Am*cos(Wm*t);
subplot(2,2,1);
plot(t,m);
title('Message Input Signal');
xlabel('Time --->');
ylabel('Amplitude --->')
Wc= 2*pi*fc;
c = Ac*cos(Wc*t);
subplot(2,2,2);
plot(t,c);
title('Carrier Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
% Phase Modulation
s_pm = Ac*cos(Wc*t+kp*Am.*cos(Wm*t));
subplot(2,2,3);
plot(t,s_pm);
title('Phase Modulated Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
% Phase Demodulation
x = hilbert(s_pm);
z = unwrap(angle(x));
y = z - 2*pi*fc*t;
subplot(2,2,4) ;
plot(t,y/kp + 1.25) ;
ylim([-1 1]) ;
title('Phase Demodulated Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
Q3. Add the Noise in the channel, and then perform the
demodulation in case of FM and PM.
Matlab Code :
clc;
clear;
fs = 8000;
fm = 10;
fc = 200;
t=(0:0.2*fs)/fs;
Am = 1;
Ac = 1;
kf = input('Frequency Sensitivity(kf) = ');
kp = input('Phase Sensitivity(kp) = ');
Wm =2*pi*fm;
m = Am*cos(Wm*t);
subplot(3,2,1);
plot(t,m);
title('Message Input Signal');
xlabel('Time --->');
ylabel('Amplitude --->')
Wc= 2*pi*fc;
c = Ac*cos(Wc*t);
subplot(3,2,2);
plot(t,c);
title('Carrier Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
nMean = 0 ;
nSigma = 0.1 ;
n = nMean + nSigma*randn(size(t));
% Frequency Modulation
s_fm = Ac*cos(Wc*t+((2*pi*kf*Am)/Wm)*sin(Wm*t)) + n;
subplot(3,2,3);
plot(t,s_fm);
title('Frequency Modulated Signal With Noise');
xlabel('Time --->');
ylabel('Amplitude --->');
% Frequency Demodulation ;
s = Ac*(Wc +
2*pi*kf*Am*cos(Wm*t)).*sin(Wc*t+((2*pi*kf*Am)/Wm)*sin(Wm*t)) + n;
x = abs(hilbert(s));
y = x/(2*pi*kf) - 2 + n;
subplot(3,2,4) ;
plot(t,y + 0.4) ;
title('Frequency Demodulated Signal');
xlabel('Time --->');
ylabel('Amplitude --->');
% Phase Modulation
s_pm = Ac*cos(Wc*t+kp*Am.*cos(Wm*t)) + n;
subplot(3,2,5);
plot(t,s_pm);
title('Phase Modulated Signal With Noise');
xlabel('Time --->');
ylabel('Amplitude --->');
% Phase Demodulation
x = hilbert(s_pm);
z = unwrap(angle(x));
y = z - 2*pi*fc*t;
subplot(3,2,6) ;
plot(t,y/kp + 1.25 + n) ;
ylim([-1 1]) ;
title('Phase Demodulated Signal');
xlabel('Time --->');
ylabel('Amplitude --->');