ADVANCED ELECTRONIC SYSTEMS DESIGN
by barkkathulla[ Edit ] 2012-09-21 09:55:28
clc;
clear all;
g=input('enter the generator matrix');
disp('g='); disp(g);
disp('the order of the linear block code for given Genertaor matrix is');
[n,k]=size(transpose(g));disp(n);disp(k);
for i=1:2^k
for j=k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else
u(i,j)=0;
end
end
end
disp('the possible code words are:');disp(u);
c=rem(u*g,2)
disp('the min hamming distance dmin for given block code is=');disp(c);
d_min=min(sum((c(2:2^k,
)'));
r=input('enter the received code word:');
p=[g(:,n-k+2:n)];
h=[transpose(p),eye(n-k)];
disp('hamming code');
ht=transpose(h);
disp('syndrome of a given code word is :');
s=rem(r*ht,2)
for i=1:1:size(ht)
if(ht(i,1:3)==s)
r(i)=1-r(i);
break;
end
end
disp('the error is in bit:');
disp(i);
disp('the corrected code word is:');
disp(r);