% Aim: Implementation Of linear Block Code

clc;

clear all;

% Input Generator Matrix

g=input('Enter The Generator Matrix: ')

disp ('G = ')

disp ('The Order of Linear block Code for given Generator Matrix is:')

[n,k] = size(transpose(g))

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

u;

disp('The Possible Codewords are :')

c = rem(u*g,2)

disp('The Minimum Hamming Distance dmin for given Block Code is= ')

d_min = min(sum((c(2:2^k,:))'))

% Code Word

r = input('Enter the Received Code Word:')

p = [g(:,n-k+2:n)];

h = [transpose(p),eye(n-k)];

disp('Hammimg Code')

ht = transpose(h)

disp('Syndrome of a Given Codeword 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:')

i

disp('The Corrected Codeword is :')

r

%******************** OUTPUT *******************

Enter The Generator Matrix: [1 0 0 0 1 0 1;0 1 0 0 1 1 1;0 0 1 0 1 1 0;0 0 0 1 0 1 1]

g =

1 0 0 0 1 0 1

0 1 0 0 1 1 1

0 0 1 0 1 1 0

0 0 0 1 0 1 1

G =

The Order of Linear block Code for given Generator Matrix is:

n =

7

k =

4

The Possible Codewords are :

c =

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 1 1

0 1 0 1 1 0 0

0 1 1 0 0 0 1

0 1 1 1 0 1 0

1 0 0 0 1 0 1

1 0 0 1 1 1 0

1 0 1 0 0 1 1

1 0 1 1 0 0 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

The Minimum Hamming Distance dmin for given Block Code is=

d_min =

3

Enter the Received Code Word:[1 0 0 0 1 0 0]

r =

1 0 0 0 1 0 0

Hammimg Code

ht =

1 0 1

1 1 1

1 1 0

0 1 1

1 0 0

0 1 0

0 0 1

Syndrome of a Given Codeword is :

s =

0 0 1

The Error is in bit:

i =

7

The Corrected Codeword is :

r =

1 0 0 0 1 0 1

## Sunday, June 8, 2008

### Linear Block Code

Posted by Lionel at 3:51 AM

Subscribe to:
Post Comments (Atom)

## 7 comments:

thanks, it helps a lot.

can you help me to know how generator matrix for linear codes for given n and k such as n=19 and k=8 can be produced?(using matlab)

Do you know about Singleton bound by any chance?

Who know how to encode document file .doc to this linear block code?...anyone??..please help me

??? Error using ==> horzcat

CAT arguments dimensions are not consistent.

Error in ==> ITC at 29

h = [transpose(p),eye(n-k)];

getting this error when implementing (6,3) LBC wid this code. plz advice

when i am ilplementing i got an error in this line

??? Subscript indices must either be real positive integers or logicals.

Error in ==> linblkcoderx at 26

p = (g(:,n-k+2:n));

i want matlab code for cyclic code generator

Post a Comment