You are on page 1of 5

Matlab code:

dt=1e-8;
Fs=1/dt;
t=0:dt:0.01;
Ac=3;
fm=400;
fc=50000;
Nt=length(t);
dev=7500;
m=sin(2*pi*fm*t);

figure
subplot(3,1,1)
plot(t,m)
title('message signal');
xlabel('time (sec)')

sFM=fmmod(m,fc,Fs,dev);
subplot(3,1,2)
plot(t,sFM)
title('FM modulated signal')
xlabel('time (sec)')

dsFM=sFM(1);
for k=2:Nt
dsFM(k)=(sFM(k)-sFM(k-1))/dt;
end
dsFMplus=hilbert(dsFM);
dsFMtilde=dsFMplus.*exp(-j*2*pi*fc*(t));
mFMdemod=abs(dsFMtilde);
mFMdemod=mFMdemod-mean(mFMdemod);
subplot(3,1,3)
plot(t,mFMdemod)
title('FM detector output')
xlabel('time (seconds)')
graph:
LAB NO.08

ANALOG AND DIGITAL COMMUNICATION

SUBMITTED BY: ASAD khan

SUBMITTED TO:MA AM QURATUL AIN

ROLL NO.36

DATE:24/05/2018
Lab task:

Code:
dt=1e-5; %sampling rate seconds
Fs=1/dt;
t=0:dt:0.1;
Ac=1;
fm=10;
fc=1000;
Nt=length(t);
dev=800; %freq dev
m=sin(2*pi*fm*t); %msg signal
%plots
figure
subplot(3,1,1)
plot(t,m);
title('original signal');
xlabel('time (sec)')

%frequency modulation

sFM=fmmod(m,fc,Fs,dev);
subplot(3,1,2)
plot(t,sFM)
title('FM modulated signal')
xlabel('time (sec)')

%FM demodulation %%derivative followed by envelop detection


dsFM=sFM(1); %derivative of point 1 is constant storing it first
for k=2:Nt
dsFM(k)=(sFM(k)-sFM(k-1))/dt;
end

%envelop detection
dsFMplus=hilbert(dsFM); %pre-envelop ( envelope detection)
dsFMtilde=dsFMplus.*exp(-j*2*pi*fc*(t)); %complex envelop (
phase of above detected signal)

mFMdemod=abs(dsFMtilde); %envelop detector output (magnitude of


above detected signal)

mFMdemod=mFMdemod-mean(mFMdemod); %removing DC component

%plots
subplot(3,1,3)
plot(t,mFMdemod)
title('FM detector output')
xlabel('time (seconds)')

graph:

You might also like