0% found this document useful (0 votes)
49 views2 pages

DSP Motion Control

This document demonstrates encoding and decoding of a (6,3) linear block code. It defines a generator matrix, encodes a data vector into a codeword, calculates the weight and parity check matrix, loads the decoding table with error patterns, decodes a received codeword by finding the closest codeword and flipping bits to correct any errors.

Uploaded by

Rutul Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views2 pages

DSP Motion Control

This document demonstrates encoding and decoding of a (6,3) linear block code. It defines a generator matrix, encodes a data vector into a codeword, calculates the weight and parity check matrix, loads the decoding table with error patterns, decodes a received codeword by finding the closest codeword and flipping bits to correct any errors.

Uploaded by

Rutul Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

%(6,3) linear block code :

G=input('Enter Generator matrix : ');


[k n] = size(G);
for i=1:2^k
for j=1:k
D(i,j) = bitget(i-1,4-j);
end
end
C = encode(D,n,k,'linear/fmt',G)
wt=gfweight(G)
p=gen2par(G)
t=syndtable(p)
r=input('Received code : ');
for i=1:2^k
for j=1:2^k
if r==xor(C(j,:),t(i,:));
cc=C(j,:);
e_bit=t(i,:);
break;
end
end
end
newr=xor(r,e_bit)

output:
Enter Generator matrix : [ 1 1 0 1 0 0;1 0 1 0 1 0;0 1 1 0 0 1]
C=
0
0
1
1
1
1
0
0

0
1
0
1
1
0
1
0

0
1
1
0
0
1
1
0

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

0
1
0

0
0
1

1
1
0

1
0
1

0
1
1

wt =
3

p=
1
0
0

Single-error patterns loaded in decoding table. 1 rows remaining.

2-error patterns loaded. 0 rows remaining.


t=
0
0
0
0
1
0
0
1

0
0
1
0
0
0
0
0

0
1
0
0
0
0
0
0

0
0
0
0
0
0
1
0

0
0
0
0
0
1
0
0

0
0
0
1
0
0
0
1

Received code : [0 1 1 0 1 1]
newr =
0

You might also like