%cyclic code generator
clear all;
clc;
n=input('enter the length of codeword=');
k=input('enter the length of message=');
gen_coff=input('enter the generator coefficient=');
m=input('enter the message=');
y=[1]
a=zeros(1,n-k)
z1=cat(2,y,a)
x=conv(z1,m)
x1=abs(rem(x,2))
[q,r]=deconv(x1,gen_coff)
r1=abs(rem(r,2))
codeword=xor(x1,r1)
O/P-
enter the length of codeword = 7
enter the length of message = 4
enter the generator coefficient = [3 2 0]
enter the message = [1 1 0 1 1 0 1]
y = 1
a =
0 0 0
z1 =
1 0 0 0
x =
1 1 0 1 1 0 1 0 0 0
x1 =
1 1 0 1 1 0 1 0 0 0
q =
0.3333 0.1111 -0.0741 0.3827 0.0782 -0.0521 0.3681 -0.2454
r =
0 0 0 0 0 0 0 0 0.490 0
r1 =
0 0 0 0 0 0 0 0 0.490 0
codeword =
1 1 0 1 1 0 1 0 1 0
No comments:
Post a Comment