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

LBC Case Study

The document describes a MATLAB program for encoding and decoding a Linear Block Code (LBC). It prompts the user to input parameters such as the length of the code, the generator matrix, and the received message, then calculates the codeword and checks for errors using a parity matrix. The program outputs the syndrome and identifies any errors in the received message, providing the corrected codeword if necessary.

Uploaded by

Aayush Deshmukh
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)
58 views2 pages

LBC Case Study

The document describes a MATLAB program for encoding and decoding a Linear Block Code (LBC). It prompts the user to input parameters such as the length of the code, the generator matrix, and the received message, then calculates the codeword and checks for errors using a parity matrix. The program outputs the syndrome and identifies any errors in the received message, providing the corrected codeword if necessary.

Uploaded by

Aayush Deshmukh
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

Linear Block Code

• Code

% Name- Aayush Deshmukh


% Roll no.- 2163
% Subject- Linear Block code
clc;
clear all;
n=input("Enter n:");
k=input('Enter k:');
d=input('Enter data:');
G=input("Enter Generator Matrix:");
c=d*G;
C=rem(c,2);
disp('Data is:');
disp(d);
disp('Generator Matrix is:');
disp(G);
disp('CODE is: ');
disp(C);

%Decoding of LBC

p=input("Enter The Parity Matrix:");


h=horzcat(p.', eye(n-k));
ec1=vertcat(zeros(1,n), eye(n))
ec2=vertcat(zeros(1,n-k),h.')
disp('ERROR DECODING TABLE:');
ec=horzcat(ec1, ec2);
disp(ec);
r=input('ENTER THE RECEIVED MESSAGE:');
s=mod(r*h.',2);
disp('SYNDROME IS (S):');
disp(s);

if s==zeros(1,n-k)
disp('NO ERROR IN RECEIVED MESSAGE');
else
disp('ERROR IN BIT:');
d=find(ismember (ec2,s,'rows'));
disp(d-1);
r(d-1)=(r(d-1)+1);
disp('CORRECTED CODEWORD IS:');
R=xor(r,ecl(d-1));
disp(R);
end

• Output

Enter n:
7
Enter k:
4
Enter data:
[ 1 1 0 0 ]
Enter Generator Matrix:
[ 1 0 0 0 1 1 0 ; 0 1 0 0 0 1 1 ; 0 0 0 1 1 1 1; 0 0 0 1 1 0 1]
Data is:
1 1 0 0
Generator Matrix is:
1 0 0 0 1 1 0
0 1 0 0 0 1 1
0 0 0 1 1 1 1
0 0 0 1 1 0 1

CODE is:
1 1 0 0 1 0 1

Enter The Parity Matrix:


[ 1 1 0; 0 1 1; 1 1 1; 1 0 1]

ec1 =

0 0 0 0 0 0 0
1 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 1 0 0 0
0 0 0 0 1 0 0
0 0 0 0 0 1 0
0 0 0 0 0 0 1

ec2 =

0 0 0
1 1 0
0 1 1
1 1 1
1 0 1
1 0 0
0 1 0
0 0 1

ERROR DECODING TABLE:


0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 1 1 0
0 1 0 0 0 0 0 0 1 1
0 0 1 0 0 0 0 1 1 1
0 0 0 1 0 0 0 1 0 1
0 0 0 0 1 0 0 1 0 0
0 0 0 0 0 1 0 0 1 0
0 0 0 0 0 0 1 0 0 1

ENTER THE RECEIVED MESSAGE:


[0 1 1 1 1 0 1]

SYNDROME IS (S):
1 0 0

ERROR IN BIT:
5

CORRECTED CODEWORD IS:


0 1 1 1 1 0 1

You might also like