Matlab program for plotting of Bit error rate when
- One signal transmitted per bit
- Three signals transmitted per bit
Bg (Message Bits) >>s1 (Transmitting signal) >> s1t (Affected by AWGN) >>s1r (Regenerated bit by received signal)
Process when three signal transmitted per bit
Bg (Message Bits)>> s2 (Transmitting signal) >> s2t (Affected by AWGN) >>s2ro (Received signal) >> s2r (Regenerated bit by received signal)
Matlab code
clc; close all; clear all;
Tbit=input('Enter the no of bit = ');
y=rand(1,Tbit);
for i=1:length(y)
if y(i)<=0.5
Bg(i)=0;
s1(i)=-1;
s2(3*i-2:3*i)=-1;
else
Bg(i)=1;
s1(i)=1;
s2(3*i-2:3*i)=1;
end;
end;
snr=1:10;
n1=[];m1=[];m3=[];
for i=1:length(snr)
s1t=awgn(s1,snr(i));
s2t=awgn(s2,snr(i));
for j=1:length(s1t)
ifs 1t(j)<=0.5
s1r(j)=0;
else
s1r(j)=1;
end;
end;
for j=1:length(s2t)
if s2t(j)<=0.5
s2ro(j)=0;
else
s2ro(j)=1;
end;
end;
for j=1:length(s2ro)/3
if sum(s2ro(3*j-2:3*j))>1
s2r(j)=1;
else
s2r(j)=0;
end;
end;
ber1(i)=sum(xor(Bg,s1r)/Tbit);
ber3(i)=sum(xor(Bg,s2r)/Tbit);
end;
semilogy(snr,ber1);
hold on;
semilogy(snr,ber3,'r');
xlabel('SNR-->');
ylabel('Bit Error Rate-->');
title('Comparison of Bit Error Rate');
legend('1 signal transmitted per bit','3 signal transmitted per bit');
Command window
Enter the no of bit = 10000
No comments:
Post a Comment