Question: In this assignment, we use Matlab to build an FM modulator and demodulator. The Matlab program is given by ExampleFM.m on page 292 of the
In this assignment, we use Matlab to build an FM modulator and demodulator. The Matlab program is given by ExampleFM.m on page 292 of the textbook. The modulating signal m(t) is triangular with amplitude (-1, +1). Run a slightly modified version of the Matlab program to generate:
The modulating signal m(t)
The FM modulated signal
The amplitude spectrum of the FM signal
The demodulated signal
The original (unmodified) Matlab program ExampleFM.m is reproduced below:
% (ExampleFM.m)
% This program uses triangl.m to illustrate frequency modulation
% and demodulation
ts=1.e-4;
t=-0.04:ts:0.04;
Ta=0.01;
m_sig=triangl((t+0.01)/Ta)-triangl((t-0.01)/Ta);
Lfft=length(t); Lfft=2ceil(log2(Lfft));
M_fre=fftshift(fft(m_sig,Lfft));
freqm=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
B_m=100; %Bandwidth of the signal is B_m Hz.
% Design a simple lowpass filter with bandwidth B_m Hz.
h=fir1(80,[B_m*ts]);
%
kf=160*pi;
m_intg=kf*ts*cumsum(m_sig);
s_fm=cos(2*pi*300*t+m_intg);
s_pm=cos(2*pi*300*t+pi*m_sig);
Lfft=length(t); Lfft=2ceil(log2(Lfft)+1);
S_fm=fftshift(fft(s_fm,Lfft));
S_pm=fftshift(fft(s_pm,Lfft));
freqs=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
s_fmdem=diff([s_fm(1) s_fm])/ts/kf;
s_fmrec=s_fmdem.*(s_fmdem>0);
s_dec=filter(h,1,s_fmrec);
% Demodulation
% Using an ideal LPF with bandwidth 200 Hz
Trange1=[-0.04 0.04 -1.2 1.2];
figure(1)
subplot(211);m1=plot(t,m_sig);
axis(Trange1); set(m1,Linewidth,2);
xlabel({\it t} (sec)); ylabel({\it m}({\it t}));
title(Message signal);
subplot(212);m2=plot(t,s_dec);
set(m2,Linewidth,2);
xlabel({\it t} (sec)); ylabel({\it m}_d({\it t}))
title(demodulated FM signal);
figure(2)
subplot(211);td1=plot(t,s_fm);
axis(Trange1); set(td1,Linewidth,2);
xlabel({\it t} (sec)); ylabel({\it s}_{ m FM}({\it t}))
title(FM signal);
subplot(212);td2=plot(t,s_pm);
axis(Trange1); set(td2,Linewidth,2);
xlabel({\it t} (sec)); ylabel({\it s}_{ m PM}({\it t}))
title(PM signal);
figure(3)
subplot(211);fp1=plot(t,s_fmdem);
set(fp1,Linewidth,2);
xlabel({\it t} (sec)); ylabel({\it d s}_{ m FM}({\it t})/dt)
title(FM derivative);
subplot(212);fp2=plot(t,s_fmrec);
set(fp2,Linewidth,2);
xlabel({\it t} (sec));
title(rectified FM derivative);
Frange=[-600 600 0 300];
figure(4)
subplot(211);fd1=plot(freqs,abs(S_fm));
axis(Frange); set(fd1,Linewidth,2);
xlabel({\it f} (Hz)); ylabel({\it S}_{ m FM}({\it f}))
title(FM amplitude spectrum);
subplot(212);fd2=plot(freqs,abs(S_pm));
axis(Frange); set(fd2,Linewidth,2);
xlabel({\it f} (Hz)); ylabel({\it S}_{ m PM}({\it f}))
title(PM amplitude spectrum);
PLEASE INCLUDE PLOTS FROM MATLAB (PLEASE)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
