Code:
r=input ('enter received data r=');
h=input ('enter the transpose matrix number h=');
d=r*h;
for i=1:length(d),
y=d(i);
x=mod(y,2);
d(i)=x;
end
disp('syndrom=');
disp(d);
l=length(r);
e=zeros(1,l);
for i=1:l;
e(i)=1;
s=e*h;
if s==d
i==l;
else
e(i)=0;
end
end
disp('error=');
disp(e);
c=xor(r,e);
disp('original data=');
disp(c)
Output:
enter received data r=[1 0 1
1 1 0 1]
enter the transpose matrix
number h=[1 0 0 0;0 1 1 0;1 1 0 1;0 1 0
1 ;1 1 0 0;0 0 1 0; 1 0 0 1]
Syndrome=
0
1 0 1
Error=
0
0 0 1
0 0 0
Original data=
1
0 1 0
1 0 1
0 comments:
Post a Comment