LINEAR
BLOCKCODES
AIM
To
detect and correct the error accruing in the transmitted data with
the help
of
linear block codes.
THEORY
A
code is said to be linear if any two code word in the code, can be
added in module 2 arithmetic to Produce a third codeword in the code.
The (n-k) bits in the remaining portion are computed from the message
bits in the accordance with the prescribed encoding rule that
determines a mathematical structure of the code, then use frame to
get the syndrome calculation.
The
hamming weight of the code vector C is defined in the number of non
zero elements in the code vector. The minimum distance of the linear
block code is defiend in the smallest hamming distance between any
pair of code vector in code.
Algorithm
- Get the generator matrix value.
- Calculate the order of given matrix.
- calculate the code word.
- calculate the minimum ha
- Get the received code word.
- Display the hamming code
- Display the syndrome of the code word.
- Calculate the error in the bit.
- Display the correlated code word.PROGRAM#######################################clc;clear all;close all;%input generator matrixg=input('enter the generator matrix:')disp('G=')disp('the order of linear block code for given generator mathrix is:');[n,k]=size(transpose(g))for i=1:2^kfor j=k:-1:1if rem(i-1,2^(-j+k+1))>=2^(-j+k)u(i,j)=1;elseu(i,j)=0;endendendu;disp('the possible code word 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 wordr=input('enter the recieved 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 code word is:');s=rem(r*ht,2)for i=1:1:size(ht)if(ht(i,1:3)==5)r(i)=1-r(i);break;endenddisp('the error is in bit:');i;disp('the correct codeword is:');r;###########################################################################OUTPUTEnter the generator matrix:[1000101;0100111;0010110;0001011]g =1000101010011100101100001011G = The order of linear block code for given generator mathrix is:n = 7k = 4The possible code word are:0000000000101100101100011101000011101011000110001011101010001001001110101001110110001100010110100111101001111111The minimum hamming distance dmin for given block code is:d_min =3Enter the received code word:[1000100]r=1000100Hamming codeH=101111110011100101001
Syndrome of t given codeword is:s=001The error is in bit :i=7The corrected code word is : r=100010.ResultThus the error is detected and corrected n the transmitted code by using linear block codes.