75% found this document useful (4 votes)
8K views

Linear Block Code Matlab

The linear block code program defines a (7,4) linear block code with generator matrix G. It calculates the possible codewords, finds the minimum Hamming distance to be 3, and demonstrates error correction by finding the syndrome and flipping the bit in the received codeword indicated by the syndrome.

Uploaded by

sanjeevnokia
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
75% found this document useful (4 votes)
8K views

Linear Block Code Matlab

The linear block code program defines a (7,4) linear block code with generator matrix G. It calculates the possible codewords, finds the minimum Hamming distance to be 3, and demonstrates error correction by finding the syndrome and flipping the bit in the received codeword indicated by the syndrome.

Uploaded by

sanjeevnokia
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Linear block codes program: clc; clear all; %input generated matrix g=input('enter the generator matrix:'); disp('G=')

disp('the order of the 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=') d_min=min(sum((c(2:2^k,:))')) %codeword r=input('enter the received code word:') p=[g(:,n-k+2:n)]; h=[transpose(p),eye(n-k)]; disp('hamming 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=the order of the linear block code for given generator matrix is:n = 7 k=4 syndrome of a given codeword is: s= 0 0 1

the possible codewords are: c= 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 1 0 1

the minimum hamming distance dmin for given block code d_min = 3 enter the received code word:[1 0 0 0 1 0 0] r =1 0 0 0 1 0 0

hamming code ht = 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1

the error is in bit:i = 7 the corrected codeword is: r= 1 0 0 0 1 0 1

You might also like