0% found this document useful (0 votes)
398 views

Linear Block Code Matlab PDF

The document describes a linear block code program. It defines a generator matrix, calculates the possible codewords, and determines the minimum hamming distance for the given block code. It then takes a received codeword as input, calculates the syndrome to detect errors, corrects a single-bit error by flipping the erroneous bit, and outputs the corrected codeword.

Uploaded by

saisree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
398 views

Linear Block Code Matlab PDF

The document describes a linear block code program. It defines a generator matrix, calculates the possible codewords, and determines the minimum hamming distance for the given block code. It then takes a received codeword as input, calculates the syndrome to detect errors, corrects a single-bit error by flipping the erroneous bit, and outputs the corrected codeword.

Uploaded by

saisree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Linear block codes program: the possible codewords are:

clc; c=
clear all;
%input generated matrix 0 0 0 0 0 0 0
g=input('enter the generator matrix:');
disp('G=') 0 0 0 1 0 1 1
disp('the order of the linear block code
for given generator matrix is:') 0 0 1 0 1 1 0
[n,k]=size(transpose(g))
for i=1:2^k 0 0 1 1 1 0 1
for j=k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k) 0 1 0 0 1 1 1
u(i,j)=1;
else 0 1 0 1 1 0 0
u(i,j)=0;
end 0 1 1 0 0 0 1
end
end 0 1 1 1 0 1 0
u;
disp('the possible codewords are:') 1 0 0 0 1 0 1
c=rem(u*g,2)
1 0 0 1 1 1 0
disp('the minimum hamming distance dmin
for given block code=')
1 0 1 0 0 1 1
d_min=min(sum((c(2:2^k,:))'))
%codeword
1 0 1 1 0 0 0
r=input('enter the received code word:')
p=[g(:,n-k+2:n)]; 1 1 0 0 0 1 0
h=[transpose(p),eye(n-k)];
disp('hamming code') 1 1 0 1 0 0 1
ht=transpose(h)
disp('syndrome of a given codeword is:') 1 1 1 0 1 0 0
s=rem(r*ht,2)
for i=1:1:size(ht) 1 1 1 1 1 1 1
if (ht(i,1:3)==s)
r(i)=1-r(i); the minimum hamming distance dmin for given block code
break; d_min = 3
end
end enter the received code word:[1 0 0 0 1 0 0]
disp('the error is in bit:')
i r =1 0 0 0 1 0 0
disp('the corrected codeword is:')
r hamming code

Output: ht =

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 1


1 0;0 0 0 1 0 1 1]
1 1 1
G=the order of the linear block code for given generator matrix
is:n = 7 1 1 0

k=4 0 1 1

syndrome of a given codeword is: 1 0 0

s= 0 0 1 0 1 0

the error is in bit:i = 7 0 0 1

the corrected codeword is:

r= 1 0 0 0 1 0 1

You might also like