0% found this document useful (0 votes)
114 views

Correlative Coding MATLAB CODE

This MATLAB program implements correlatve coding. It generates random binary data, performs precoding, polar conversion, and duo-binary encoding. It then adds white Gaussian noise at different SNR values and calculates the bit error rate for each. Finally, it plots the BER versus SNR.

Uploaded by

S. Magidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views

Correlative Coding MATLAB CODE

This MATLAB program implements correlatve coding. It generates random binary data, performs precoding, polar conversion, and duo-binary encoding. It then adds white Gaussian noise at different SNR values and calculates the bit error rate for each. Finally, it plots the BER versus SNR.

Uploaded by

S. Magidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MATLAB PROGRAM TO IMPLIMENT CORRELATIVE CODING

=============================================================================
clc;
close all;
clear all;
b=randint(1,10000);
a(1)=1;
%precoder output
for i=2:length(b)+1
a(i)=xor(a(i-1),b(i-1));
end
% polar conversion
for l=1:length(a)
if a(l)==1
c(l)=1;
else

c(l)=-1;

end

end

% duo binar encoder


for k=2:length(c)
g(k-1)=c(k)+c(k-1);
end

% detection rule
for j=1:length(g)
if g(j)==0
h(j)=1;
else
h(j)=0;
end
end
snr=[2 4 6 8]; % snr values
z1=awgn(h,snr(1)); % adding white gaussian to output at 1st snr values
for k=1:1:length(z1)
if z1(k)>0
x1(k)=1;
else
x1(k)=0;
end
end
br1 = biterr(h,x1); % camparing output to input and calculating number of bits

err1=br1/length(h); % number of bit errors to total no of bits i.e bit error


rate

z2=awgn(h,snr(2)); % same process at snr 2nd value


for q=1:1:length(z2)
if z2(q)>0
x2(q)=1;
else
x2(q)=0;
end
end
br2 = biterr(h,x2);

err2=br2/length(h);
z3=awgn(h,snr(3));
for w=1:1:length(z3)
if z3(w)>0
x3(w)=1;
else
x3(w)=0;
end
end
br3 = biterr(h,x3);

err3=br3/length(h);
z4=awgn(h,snr(4));
for e=1:1:length(z4)
if z4(e)>0
x4(e)=1;
else
x4(e)=0;
end
end
br4 = biterr(h,x4);
err4=br4/length(h);
b=[err1 err2 err3 err4];

b=[err1 err2 err3 err4];


plot(snr,b);
grid on;

xlabel('snr---->');
ylabel('BER');

You might also like