Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Coding:

clc; clear all; close all; n=input('Enter the no. of registers:'); len=(2^n)-1; r=zeros(1,n); r(1)=1; for i=1:1:len pn(i)=xor(r(1),r(n)); for j=n:-1:2 r(j)=r(j-1); end r(1)=pn(i); end display(['PN SEQUENCE: ',num2str(pn)]); b1=0; b2=0; disp('BALANCE PROPERTY:'); for i=1:1:len if(pn(i)==1) b1=b1+1; else b2=b2+1; end end disp(['No. of ones in the sequence:',num2str(b1)]); disp(['No. of zeros in the sequence:',num2str(b2)]); if(b1==(b2+1)) disp('BALANCE Property is Satisfied'); else disp('BALANCE Property is not Satisfied'); end disp('RUN PROPERTY:'); r=0; for i=1:1:(len-1) if(pn(i)~=pn(i+1)) r=r+1; end end display(['No. of Runs:',num2str(r)]); if(r==2^(n-1)) disp('RUN Property is Satisfied'); else disp('RUN Property is not Satisfied');

end disp('AUTO-CORRELATION PROPERTY:'); x=pn; y=pn(len); for i=len:-1:2 x(i)=x(i-1); end x(1)=y; a=0; d=0; for i=1:1:len; if(x(i)==pn(i)) a=a+1; else d=d+1; end end display(['No. of Agreements :',num2str(a)]); display(['No. of Disagreements :',num2str(d)]); if(d==a+1) disp('AUTO-CORRELATION Property is Satisfied'); else disp('AUTO-CORRELATION Property is not Satisfied'); end if(b1==(b2+1)&&r==2^(n-1)&&d==a+1) disp('The Generated Sequence is a PSEUDO NOISE SEQUENCE'); else disp('The Generated Sequence is not a PSEUDO NOISE SEQUENCE'); end

Output:
Enter the no. of registers:4 PN SEQUENCE: 1 1 1 0 1 0 1 1 0 0 1 0 0 0 1 BALANCE PROPERTY: No. of ones in the sequence:8 No. of zeros in the sequence:7 BALANCE Property is Satisfied RUN PROPERTY: No. of Runs:8 RUN Property is Satisfied AUTO-CORRELATION PROPERTY: No. of Agreements :7 No. of Disagreements :8 AUTO-CORRELATION Property is Satisfied The Generated Sequence is a PSEUDO NOISE SEQUENCE

You might also like