You are on page 1of 3

LAB 09

FM demodulation and SNR


OBJECTIVE:
This lab is about the SNR and FM demodulation. We should to learn how to calculate SNR and
how to implement FM modulation.
PROCEDURE:
First of all we will make a two files and then with the help of that file we will run the file of
demodulation.
MATHEMATICAL:

SNR
Gamma_db SIMULATION THEORY
-10 -10.87 -10
-5 -5.97 -5
0 0 0
5 4.92 5
10 9.89 10
15 14.76 15
20 19.91 20
25 24.90 25
30 29.88 30

CODE: FILE(1):
function y=FM_demod(r,fc,Fs,A,B)
%BPF of BW=2B;
N=length(r);
Ts=1/Fs;
t=(0:N-1)*Ts;
%N=length(r);
f=Fs/N*(-N/2:N/2-1);
R=fftshift(fft(r,N)/N);
H_BPF=zeros(size(f));
ind1=find(abs(f)>= fc-B & abs(f)<=fc+B);
H_BPF(ind1)=1;
X=R.*H_BPF;
x=N*ifft(fftshift(X),N);
d=x.*(1*cos(2*pi*fc*t));
%LPF
H=zeros(size(f));
ind=find(f>= -B & f<=B);
H(ind)=2/1;
D=fftshift(fft(d,N)/N);
Y=D.*H;y=N*ifft(fftshift(Y),N);
y=y+A;
end

CODE: FILE(2):
Am=2;fm=2000;
Ac=500;
fc=100;
Fs=50*fc;
Ts=1/Fs;
N=1e+5;
t=(0:N-1)*Ts;
m=Am*cos(2*pi*fm*t);
Pm=1/N*sum(abs(m).^2);
B=fm;
mu=1 ;A=Am/mu;
figure
plot(t,x); axis([0.001 0.01 -0.00000000000001 0.00000000000001]);
x=FM_mod(m,fc,Fs,A);
Px=1/N*sum(abs(x).^2);
gam_dB=5;
gam=10^(gam_dB/10);
sig2w=Px/(gam*2*B/Fs);
w=sqrt(sig2w)*randn(1,N);
r=x+w;
y=FM_demod(x,fc,Fs,A,B);
plot(t,m,t,y,'-');axis([0.001 0.1 -0.00000000000001 0.00000000000001]);
Py=1/N*sum(abs(y).^2)
yn=FM_demod(r,fc,Fs,A,B);
Pn=1/N*sum(abs(y-yn).^2)
SNR_ouput=10*log10(Py/Pn)
OUT PUT:
>> llllll

Py =

0.7500

Pn =

0.2394

SNR_ouput =

4.9595
FIGURE:

10-12
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1

You might also like