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)
decmsg=decode(code ,n,k,'linear',g)
OUTPUT
enter the code digits : 7
enter the data digits : 4
enter the parity matrix it
must bei k rows and m coloums :
[ 1 1 1; 1 0 1; 1 1 0; 0 1
1]
enter 1 for systmetic and 0
for nonsystmetic1
generator matrix =
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
Code words =
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
decodedmsg =
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
0 comments:
Post a Comment