Block Code Generation Matlab Program:: EXNO: 10 (A)
Block Code Generation Matlab Program:: EXNO: 10 (A)
Block Code Generation Matlab Program:: EXNO: 10 (A)
MATLAB PROGRAM:
clc; clear; w=[1 0 0 0 1 0]; fprintf(The original code is:); disp(w); P=[1 1 0; 0 1 1; 0 0 1]; I=[1 0 0; 0 1 0; 0 0 1]; pt=P`; H=[pt,I]; ht=H; disp(ht); for(i=1:3) s1=0; for(j=1:6) s1xor(s1,ht(j,i)*w(j)); end s(i)=s1; end fprint(The syndrome is:); disp(s); for(k=1:6); if(s==ht(k,:)) temp=k;
end end fprintf(The error is in the position %d\n,temp); w(temp)=xnor(w(temp),1); disp(Corrected code is:); disp(w)
x=input(Enter the Number of Registers:); len=(2^x)-1; fprintf(\nInital state of the Registers:); for i=1:x if(i==1) r(i)=1; else r(i)=0; end fprintf(\t%d,r(i)); end
%Balance property% ones=0; zeros=0; for i=1:len if(p(i)==1) ones=ones+1; else zeros=zeros+1;
end end if(ones>zeros) fprintf(\n\nBalance property is satisfied\n); else fprintf(\n\nBalance property is not satisfied\n); end
%run length property% Run=0; for j=1(len-1) if(p(j)~=p(j+1)) run=run+1; end end frprintf(\n no of runs=%d\n,run); if(run==(2^(x-1))) fprintf(\nRun length property is satisfied); else fprintf(\nRun length property is not satisfied); end
output=p; for j=len:-1:2 output(j)=output(j-1); end output(1)=temp; fprintf(\t%d,output); agree=0; disagree=0; for j=1:len if(output(j)==p(j)) agree=agree+1; else disagree=disagree+1; end end if(disagree>agree) fprintf(\n\nAuto correlation property is satisfied\n); else fprintf(\n\nAuto correlation property is not satisfied\n); end
output 1 Enter the Number of Registers:3 Initial state of the Registers: 1 PN Sequence : 0 0 1 1 1 0 1 0 0
Balance property is statisfied No of runs=3 Runs length property is not satisfied PN Sequence after shifting: 1 0 0 1 1 1 0
Output 2 Enter the Number of Registers:4 Initial state of the Registers: 1 PN Sequence :0 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1
Balance property is satisfied No of runs=7 Runs length property is not satisfied PN Sequence after shifting:1 0 0 1 0 1 1 0 0 0 1 0 1 1 1