FSK Simulation in white noise

Status
Not open for further replies.

Bimla Pandey

Newbie level 2
Joined
Oct 19, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
27
Hi friends,
Here is two codes for FSK Simulation in white noise but theoretical and simulated curve is not coming same. PLEASE correct following two codes of FSK Simulation if possible so that both Simulated and Theoretical curve coincide and reply me how I correct these codes.

CODE 1:-

% FSK Modulation
clc;
clear all;
close all;
%GENERATE CARRIER SIGNAL
Tb=1; fc1=2;fc2=5;
t=0Tb/100):Tb;
c1=sin(2*pi*fc1*t);
c2=sin(2*pi*fc2*t);
%generate message signal
N=1000;
m=randint(1,N);
b=1;
for EbNo=1:1:12
t1=0;t2=Tb;
for i=1:1:N
t=(t1Tb/100):t2);
if m(i)==1
m_s=ones(1,length(t));
invm_s=zeros(1,length(t));
else
m_s=zeros(1,length(t));
invm_s=ones(1,length(t));
end
%message(i)=m_s;
%Multiplier
fsk_sig1=c1.*m_s;
fsk_sig2=c2.*invm_s;
fsk1=fsk_sig1+fsk_sig2;
fsk=fsk1/sum(fsk1.^2);
snr= EbNo + 10*log10(2);
ynoisy= awgn(fsk,snr,'measured'); %Noisy signal
%correlator
x1=sum(c1.*ynoisy(i));
x2=sum(c2.*ynoisy(i));
%decision device
if x1>x2
demod(i)=1;
else
demod(i)=0;
end
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
[num(b),ratio(b)]=biterr(m,demod);
en(b)=EbNo;
BER_theory(b) = berawgn(EbNo,'fsk',2,'noncoherent'); % Theoretical BER
b=b+1;
end
err=sum(num);
ph=semilogy(en,(ratio),'r*',en,(BER_theory),'b-');
set(ph,'linewidth',1.5);
xlabel('Eb/No in dB');
ylabel('BER');
legend('Simulated','Theoritical');
grid on;


CODE 2:-

clc;
clear all;
close all;
f1=10; f2=5;
Tb=1;
N=1000;
x = randint(1,N); %input bits
% FSK modulation
b=1;
for EbNo=1:1:12;
for i=1:1:N
t=i:0.001:i+1;
if x(i)==1
y(i)=sin(2*pi*f1*t);
else
y(i)=sin(2*pi*f2*t);
end
ytx=y; %Transmitted fsk signal
snr= EbNo + 10*log10(2);
ynoisy= awgn(ytx,snr,'measured'); %Noisy signal
yrx = ynoisy; %Received signal
end
%FSK demodulation
for i=1:1:N
yout1 = yrx(i).*sin(2*pi*f1*t); %multiply by carrier
ys1 =sum(yout1(i));
yout2 = yrx(i).*sin(2*pi*f2*t);
ys2 =sum(yout2(i));
%Threshold decision
if ys1>ys2
r(i)=1;
else
r(i)=0;
end
end
[num(b),ratio(b)]=biterr(x,r);
en(b)=EbNo;
pe(b)=0.5*erfc(sqrt(10^(0.6*EbNo/10)));
b=b+1;
end
err=sum(num);
ph=semilogy(en,(ratio),'r*',en,(pe),'b-');
set(ph,'linewidth',1.5);
xlabel('Eb/No in dB');
ylabel('BER');
legend('Simulated','Theoritical');
grid on;
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…