Cyclic Decoding-
clear all;
clc;
n=input('enter the length of codeword=');
k=input('enter the length of message=');
gen_coff=input('enter the generator coefficient=');
rec=input('enter the received codeword=');
[q,r]=deconv(rec,gen_coff)
syn=abs(rem(r,2))
if syn==0
disp('no error');
else
disp('error');
end
if syn==0
disp('no need of correction')
else
e=eye(n);
for i=1:n
[x,y(i,:)]=deconv(e(i,:),gen_coff);
end
z=abs(rem(y,2))
for i=1:n
if syn==z(i,:)
break
end
end
corrected=xor(rec,e(i,:))
end
Cyclic code decoding O/P-
enter the length of codeword=7
enter the length of message=4
enter the generator coefficient=[3 1 0]
enter the received codeword=[1 1 0 1 1 0 0]
q =
0.3333 0.2222 -0.0741 0.3580 0.2140
r =
0 0 0 0 0 -0.2140 0
syn =
0 0 0 0 0 0.2140 0
error
z =
0 0 0 0 0 0.0041 0
0 0 0 0 0 0.0123 0
0 0 0 0 0 0.0370 0
0 0 0 0 0 0.1111 0
0 0 0 0 0 0.3333 0
0 0 0 0 0 1.0000 0
0 0 0 0 0 0 1.0000
corrected =
1 1 0 1 1 0 1
No comments:
Post a Comment