Documente Academic
Documente Profesional
Documente Cultură
1.Write program and compare the BER for different modulation techniques. (Use MATLAB for
simulation analysis)
2.Using simulink verify the BER plot for different modulation schemes stated above.
MATLAB CODE:
1. PROBABILITY OF BIT ERROR FOR BPSK MODULATION:
clc;
clear all;
close all;
s=randn(1,10000)- 0.5;% random signal s whose amp is varying from -0.5 to 0.5
sp = var(s); % calculates the signal power
x=[];
for i=1:length(s)
if(s(i)>0)
x(i)=1;
else
x(i)=-1;
end
end
eb=1;
cp=[];
for k=1:length(s) %comparator compares the signal x before awgn channel and after
if(x(k)==r(k))
cp(k)=0;
else
cp(k)=1;
end
end
end
eb_no = 10*log10(eb./np) % calculates the Eb/No in dB
pe = ner./length(s) %pe is the ratio of no of errors by no of bits transmitted
pe_theo =(1/2)*erfc(sqrt(eb./np)) %pe using theoretical formula
snr
np
ner
semilogy(eb_no,pe_theo,'r o')
hold on
semilogy(eb_no,pe,'*');
hold off
axis([2 16 10^(-9) 10^(-1)])
grid on
title('plot of probability of error vs Eb/No in dB for BPSK ')
xlabel('Eb/No in dB')
ylabel('probability of error Pe')
legend('theoretical pe','montecarlo simulation pe');
Result:
eb_no =
Columns 1 through 7
Columns 8 through 11
pe =
Columns 1 through 7
Columns 8 through 11
0.0033 0.0009 0.0001 0
pe_theo =
Columns 1 through 7
Columns 8 through 11
snr =
2 3 4 5 6 7 8 9 10 11 12
np =
Columns 1 through 7
Columns 8 through 11
ner =
Columns 1 through 6
Columns 7 through 11
64 33 9 1 0
2. PROBABILITY OF BIT ERROR FOR QPSK MODULATION
clc;
clear all;
close all;
N=10000;
s=rand(N,1);
for i=1:length(s)
if((s(i)<0.25))
x(i,:)=sa;
elseif((s(i)<0.50))
x(i,:)=sb;
elseif((s(i)<0.75))
x(i,:)=sc;
elseif((s(i)<=1))
x(i,:)=sd;
end
end
eb=1;
for j=1:length(snr)
np(j)=sp*10^(-snr(j)/10); % depending on the value of snr np is being calculated
y=awgn(x,snr(j),np(j));%additive white gaussian noise is being added to the signal x
mn=mean(y); % finds out the mean for comparing
for i=1:length(y)
if(y(i,1) < mn(1))
r(i,1) =-1 ;
else
r(i,1)=1;
end
end
cp=[];
for k=1:N %comparator compares the signal x before awgn channel and after
if (x(k,:)==r(k,:))
cp(k)=0;
else
cp(k)=1;
end
end
end
eb_no = 10*log10(eb./np) % calculates the Eb/No in dB
pe = ner./N %pe is the ratio of no of errors by no of bits transmitted
pe_theo =(1/2)*erfc(sqrt(eb./np)) %pe using theoretical formula
snr
np
ner
semilogy(eb_no,pe_theo,'r o')
hold on
semilogy(eb_no,pe,'*');
hold off
%axis([2 15 10^(-9) 10^(0)])
grid on
title('plot of probability of error vs Eb/No in dB for QPSK ')
xlabel('Eb/No in dB')
ylabel('probability of error Pe')
legend('theoretical pe','montecarlo simulation pe');
Result:
eb_no =
Columns 1 through 7
Columns 8 through 12
8.0000 9.0000 10.0000 11.0000 12.0000
pe =
Columns 8 through 12
pe_theo =
Columns 1 through 7
Columns 8 through 12
snr =
1 2 3 4 5 6 7 8 9 10 11 12
np =
Columns 1 through 7
Columns 8 through 12
ner =
Columns 1 through 6
Columns 7 through 12
255 143 69 16 7 0
3. PROBABILITY OF BIT ERROR FOR 16-ary QAM MODULATION
clc;
clear all;
close all;
N=10000;
M=16;
x=randint(N,1,[1,M]); % the signal is varying from 1 to 16 for N samples
sp=var(x); %signal power
d=1;
mp=[-3*d 3*d; %constellation for 16-ary QAM
-d 3*d;
d 3*d;
3*d 3*d;
-3*d d;
-d d;
d d;
3*d d;
-3*d -d;
-d -d;
d -d;
3*d -d;
-3*d -3*d;
-d -3*d;
d -3*d;
3*d -3*d];
for i=1:N
sm(i,:)=mp(x(i),:); %the signal x is mapped in the constellation for 16-ary QAM
end
for k=1:length(snr)
np(k)=sp*10^(-snr(k)/10); % depending on the value of snr np is being calculated
r=awgn(sm,snr(k),np(k)); %additive white gaussian noise is being added to the signal sm
for i=1:N
for j=1:length(mp)
me(j)=(r(i,1)-mp(j,1))^2+(r(i,2)-mp(j,2))^2; %the optimum detector computes the distance
metrics
end;
[min_me decis] = min(me); %finds out the minimum
r1(i,:)=mp(decis,:); % the min indices helps in mapping back to r1 for comparing
end
cp=[];
for k1=1:N %comparator compares the signal sm before awgn channel and after
if (sm(k1,:)==r1(k1,:))
cp(k1)=0;
else
cp(k1)=1;
end
end
end
eb_no = 10*log10(eb./np) % calculates the Eb/No in dB
pe = ner./N %pe is the ratio of no of errors by no of bits transmitted
pe_theo =2*(1-(1/(sqrt(M))))*erfc(sqrt(eb./(np))) %pe for M-ary QAM
snr
np
ner
semilogy(eb_no,pe_theo,'r o')
hold on
semilogy(eb_no,pe,'*');
OUTPUT:
eb_no =
Columns 1 through 7
Columns 8 through 11
Columns 1 through 7
Columns 8 through 11
pe_theo =
Columns 1 through 7
Columns 8 through 11
snr =
2 3 4 5 6 7 8 9 10 11 12
np =
Columns 1 through 7
Columns 8 through 11
ner =
Columns 1 through 6
Columns 7 through 11
Submitted by:
L.Nagaraju(210EC3214)