help in matlab code of fsk demodulation using bandpass filter

Status
Not open for further replies.

Shruti01

Member level 3
Joined
Apr 14, 2010
Messages
67
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Mumbai, India
Activity points
1,941
Hello,
I have written a matlab code for fsk using bandpass filter but I m not getting correct plot...My code is as follows:
clc;
close all;
clear all;
no_of_bits=1000;
M=100;
no_of_samples=5000;
threshold = 0.5;
snr=[-3:1:20];
Tb = 1; % Bit duration
fc = 3/Tb; % Carrier frequency
t1=linspace(0, 1, no_of_samples);
f1=cos(2*pi*1000*t1);
f2=cos(2*pi*2000*t1);
n=50; % order of the filter
fsamp=5000; % sampling frequency
fc1=1000;
fc2=2000;
delta=500;
w1=fc1-delta;
w2=fc1+delta;
w3=fc2-delta;
w4=fc2+delta;
w11=w1/fsamp; % Frequency normalization
w22=w2/fsamp;
w33=w3/fsamp;
w44=w4/fsamp;
b1=fir1(n,[w11 w22]);
b2=fir1(n,[w33 w44]);
for i=1:10
ber(i)=0;
end
for k=1:length(snr)
sn(k)=snr(k)+6;
err(k)=0;
for m=1:M
A = rand(1,no_of_bits); % Generate a random sequence
for i=1:no_of_bits
if (A(i)>=threshold)
A(i)=1;
else
A(i)=0;
end
end
d = A(1:no_of_bits); % Binary sequence
for i=1:no_of_bits
for j = 1:length(d)
if d(j)==1
fskmod=fc1;
else
fskmod=fc2;
end
end
received=fskmod;
end
%Receiver side
b11=filter(b1,1,received); % apply bandpass filter b1 to received signal
b22=filter(b2,1,received); % apply bandpass filter b2 to received signal
for i=1:no_of_bits
if (b11>b22)
fskdmod=1;
else
fskdmod=0;
end
fskout(i)=fskdmod;
if (d(i)~=fskout(i))
err(k)=err(k)+1;
end
end
d;
fskout;
err(k);
end
ber(k)=err(k)/(no_of_bits*M)
sn(k)
end
% plot
close all
figure
semilogy(sn,ber);
axis([3 26 10^-10 10^0]);
grid on;
xlabel('snr');
ylabel('Bit Error Rate');
title('Bit error probability curve for FSK modulation');
The plot which I am getting after running the above program is as follows:
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…