%LBC DECODING
clear all;
clc;
n=input('enter the length of codevector=');
k=input('enter the message codevector=');
p=input('enter the parity matrix=');
r=input('enter the received codevector=');
a=p';
b=eye(n-k);
h=cat(2,a,b)
c=h';
s=r*c
l=rem(s,2)
if l==0
disp('no error');
else
disp('error');
end
if l==0
disp('no need of correction')
else
e=eye(n)
e1=e*c
s1=rem(e1,2)
for i=1:n
if s==s1(i,:)
break
end
end
corrected=xor(r,e(i,:))
end
O/P-
enter the length of codevector=7
enter the message codevector=4
enter the parity matrix=[1 1 1;0 1 1;1 0 1;1 1 0]
enter the received codevector=[1 0 0 0 0 0 0]
h =
1 0 1 1 1 0 0
1 1 0 1 0 1 0
1 1 1 0 0 0 1
s =
1 1 1
l =1 1 1
error
e =
1 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 1 0 0 0
0 0 0 0 1 0 0
0 0 0 0 0 1 0
0 0 0 0 0 0 1
e1 =
1 1 1
0 1 1
1 0 1
1 1 0
1 0 0
0 1 0
0 0 1
s1 =
1 1 1
0 1 1
1 0 1
1 1 0
1 0 0
0 1 0
0 0 1
corrected =
0 0 0 0 0 0 0
No comments:
Post a Comment