%to visualize the fm and phase modulation using matlab
clear all
clc
t=0:0.01:10;
Am=input('Enter Message Signal Amplitude(Am) = ');
fm=input('Enter Message Signal Frequency(fm) = ');
Ac=input('Enter Carrier Signal Amplitude(Ac) = ');
fc=input('Enter Carrier Signal Frequency(fc) = ');
kf=input('Frequency Sensitivity(kf) = ');
kp=input('Phase Sensitivity(kp) = ');
wm=2*pi*fm;
m=Am*cos(wm*t);
subplot(2,2,1)
plot(t, m);
hold on
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
wc=2*pi*fc;
c=Ac*cos(wc*t);
subplot(2,2,2)
plot(t, c);
hold on
title('Carrier Signal');
xlabel('Time (s)');
ylabel('Amplitude');
s_fm = Ac*cos(wc*t + 2*pi*kf*cumsum(m));
subplot(2,2,3)
plot(t, s_fm);
hold on
title('FM Modulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');
s_pm = Ac*cos(wc*t + kp*m);
subplot(2,2,4)
plot(t, s_pm);
hold on
title('PM Modulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');
sgtitle('Sujal Singh (04119051723)')
