Code:
clc;
clear all;
close all;
n=input('enter the code digits');
k=input('enter the data digits');
p=input('enter the parity matrix it must bei k rows
and m coloums'); disp(p)
z=input('enter 1 for systmetic and 0 for
nonsystmetic');
msg=[];
for i=0:2^k-1
msg=[msg;de2bi(i,k,'left-msb')];
end
if z==1
%p=[1 0 1;0
1 1;1 1 0];
i=eye([k k])
g=[i p]
else
g=input('enter the generator matrix in k*n ');
end
code =rem(msg*g,2)
disp('difference
matrix');
for
i=1:2^k,
for
j=1:n,
if c(i,j)==c(i+1,j)
x(i)=x(i);
else
x(i)=(x(i)+1);
end;
%x(i)=7-x(i);
end;
end;
disp(x);
a=x(1);
for
i=2:16,
if(x(i)>0)
if(a>=x(i))
a=x(i);
end
end
end
disp('Dmin');
disp(a);
disp('no
of error that can be corrected');
t=(a-1)/2;
disp(t);
Output:
enter the code digits 7
enter the data digits 4
enter the parity matrix it must be i k rows and m columns:
[ 1 1 1;
1 0 1; 1 1 0; 0 1 1]
enter 1 for systematic and 0 for nonsystematic : 1
Data
matrix
0
0 0 0
0
0 0 1
0
0 1 0
0
0 1 1
0 1
0 0
0
1 0 1
0
1 1 0
0
1 1 1
1
0 0 0
1
0 0 1
1
0 1 0
1
0 1 1
1
1 0 0
1
1 0 1
1
1 1
0
1
1 1 1
genmarix =
1 0
0 0 1
1 1
0 1
0 0 1
0 1
0 0
1 0 1
1 0
0 0
0 1 0
1 1
codewords =
0 0
0 0
0 0 0
0 0
0 1 0
1 1
0 0
1 0 1
1 0
0 0
1 1 1
0 1
0 1
0 0 1
0 1
0 1
0 1 1
1 0
0 1
1 0 0
1 1
0 1
1 1 0
0 0
1 0
0 0 1
1 1
1 0
0 1 1
0 0
1 0
1 0 0
0 1
1 0
1 1 0
1 0
1 1
0 0
0 1 0
1 1
0 1 0
0 1
1 1
1 0 1
0 0
1 1
1 1 1
1 1
0 comments:
Post a Comment