BER in BPSK

The bit error rate in bi-phase shifted keying modulation is simulated in MATLAB in the following way:

% digital modulation tester (works with large arrays and stides)

l = 10000000; % number of symbols to generate by stride
m = 100; % number of strides
clear xx; clear yy1; clear yy2; jj = 0;
for ii = -20:10:130,
EbNo = ii/10; ber1 = 0; % ber2 = 0;
for kk = 1:m,
ber1 = ber1 + digitanal( l,EbNo,1 );
% ber2 = ber2 + digitanal( l,EbNo,2 );
end
if ((ber1 > 0) & (ber2 > 0)),
jj = jj + 1;
xx(jj) = EbNo;
yy1(jj) = ber1/m;
% yy2(jj) = ber2/m;
end
EbNo
end
% semilogy(xx,yy1,’o-‘,xx,yy2,’o-‘)
semilogy(xx,yy1,’o-‘)
xlabel(‘Eb/No in dB’);
ylabel(‘BER’);
grid

where digitanal is as follows

function [ber] = digitanal( l,EbNo,type )

% this is for BPSK and QPSK actually

EbNoReal = 10^(EbNo/10);

if (type == 1), % BPSK
s = (round(rand(1,l))-0.5)*2;
n = (1/sqrt(2*EbNoReal))*randn(1,l);
r = s+n;
symbols = sign(r);
check = sum( (s == symbols) );
ber = ((l – check)/l);
end

if (type == 2), % QPSK
s1 = (round(rand(1,l))-0.5)*2;
s2 = (round(rand(1,l))-0.5)*2;
n1 = (1/sqrt(2*EbNoReal))*randn(1,l);
n2 = (1/sqrt(2*EbNoReal))*randn(1,l);
r1 = s1+n1;
r2 = s2+n2;
symbols1 = sign(r1);
symbols2 = sign(r2);
check = sum( (s1 == symbols1) & (s2 == symbols2) );
ber = ((l – check)/l);
end

end

It gave me this:

berbpsk

So, a Eb/No of 4 dB results in a BER of 0.01, which seems compatible with the analytical equation.

Last update: 3-10-2018

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.