Professional Documents
Culture Documents
%PN Sequence Generation %Auto-Correlation Property of PN Sequence %generating Mapped PN Sequence
%PN Sequence Generation %Auto-Correlation Property of PN Sequence %generating Mapped PN Sequence
%END
COMMAND WINDOW OUTPUT FOR PN-SEQUENCE AND VERIFICATION OF ITS
PROPERTIES
1 0 1 1 1 0 0
no. of zeros=
no. of ones=
>>
close all c=1/n;
clear all var=sqrt(c/2);
clc
oise=var*(randn(1,length(b)));
%input sequence as pn y=b+noise;
sequence for j=1:length(b)
if y(j)>threshold
k=input('enter the no.of r(j)=1;
flip-flops >=3 :\n');
n=2^k-1; else
r(j)=0;
a=zeros(1,n); end
b=round(rand(1,k));
end
for i=1:n
a(i)=xor(b(k),b(k-1)); %practical bit error
c=b; rate calculation
for j=1:k-1
b(j+1)=c(j); erbit=sum(r~=a);
end pber(k)=erbit/length(a);
b(1)=a(i); end
end
pber_avg(i)=sum(pber)/nsim
%generation of mapped ;
sequence end
b=2*a-1;
snrdb=0:1:10; %theoritical bit error rate
threshold=0; calculation
nsim=10;
n1=10.^((1*snrdb)/10); tber=1/2.*erfc(sqrt(n1));
c=0;
%plotting of BER vs SNR
%adding of AWGN noise to graph
mapped PN sequence
semilogy(snrdb,tber,'k--','l
for i=1:length(snrdb) inewidth',3);
for k=1:nsim hold on;
n=10^((snrdb(i))/10); grid on;
semilogy(snrdb,pber_avg,'r-*
');
title('SNR v/s BER plot for
BPSK modulation');
legend('theoritical %END
ber','practical ber');
xlabel('SNR in db');
ylabel('bit error rate');