0% found this document useful (0 votes)
97 views8 pages

Experiment No.5: Title: Aim: Apparatus: Theory: (1) Explain Linear Block Codes in Detail

This program implements a (6,3) linear block code for error detection and correction. It generates the generator and parity check matrices from the parity matrix, encodes a 3-bit message into a 6-bit codeword using the generator matrix, and calculates the hamming weight and minimum distance of the codewords. It then demonstrates syndrome decoding by calculating the syndrome vectors for different error patterns and identifying the correct error pattern by comparing to the received syndrome.

Uploaded by

abdulla qais
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)
97 views8 pages

Experiment No.5: Title: Aim: Apparatus: Theory: (1) Explain Linear Block Codes in Detail

This program implements a (6,3) linear block code for error detection and correction. It generates the generator and parity check matrices from the parity matrix, encodes a 3-bit message into a 6-bit codeword using the generator matrix, and calculates the hamming weight and minimum distance of the codewords. It then demonstrates syndrome decoding by calculating the syndrome vectors for different error patterns and identifying the correct error pattern by comparing to the received syndrome.

Uploaded by

abdulla qais
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/ 8

EXPERIMENT NO.

Title: Write a Program for coding of Linear block codes.


Aim: Error detecting and correcting using liner block code.
Apparatus: MATAB/C
THEORY:
(1) Explain Linear block codes in detail
In coding theory, a linear code is an error-correcting code for which any
linear combination of codewords is also a codeword. Linear codes are
traditionally partitioned into block codes and convolutional codes,
although turbo codes can be seen as a hybrid of these two types.[1]
Linear codes allow for more efficient encoding and decoding algorithms
than other codes (cf. syndrome decoding).
Linear codes are used in forward error correction and are applied in
methods for transmitting symbols (e.g., bits) on a communications
channel so that, if errors occur in the communication, some errors can
be corrected or detected by the recipient of a message block. The
codewords in a linear block code are blocks of symbols that are encoded
using more symbols than the original value to be sent. A linear code of
length n transmits blocks containing n symbols. For example, the [7,4,3]
Hamming code is a linear binary code which represents 4-bit messages
using 7-bit codewords. Two distinct codewords differ in at least three
bits. As a consequence, up to two errors per codeword can be detected
while a single error can be corrected. This code contains 24=16
codewords.
1) A (n,k) linear block code (LBC) is defined by 2k codewords of
length n
C = { C1….Cm}
2) A (n,k) LBC is a K-dimensional subspace of {0,1}n – (0…0) is
always a codeword – If C1,C2 ∈ C, C1+C2 ∈ C
3) Theorem: For a LBC the minimum distance is equal to the min
weight (Wmin) of the code
Wmin = min(over all Ci) Weight (Ci)

(2) Explain Generator matrix and Parity check matrix giving their
relation.

generator matrix: is binary matrix whose rows are the codeworde


belonging to some basis for the code.
For input sequence x = (x1, … , xk): Cx = xG
Every codeword is a linear combination of the rows of G
The codeword corresponding to every input sequence can be
derived from G
Since any input can be represented as a linear combination of the basis
(e1,e2,…, ek), every corresponding codeword can be represented as a
linear combination of the corresponding rows of G

Parity check matrix: is a matrix which describes the linear relations


that the components of a codeword must satisfy. It can be used to decide
whether a particular vector is a codeword and is also used in decoding
algorithms.
(3) Explain syndrome in LBC.
Syndrome decoding: is a highly efficient method of decoding a linear
code over a noisy channel That gives the correct error, one on which
errors are made. In essence, syndrome decoding is minimum distance
decoding using a reduced lookup table. This is allowed by the linearity
of the code. if L is a linear code with generator matrix G and parity
check matrix H, the syndrome f( x) is given by:

s= x*H
(4) Explain with example coding and decoding in LBC.

ENCODING
Hamming discovered a code in which a four-bit message is
represented by a seven-bit codeword. The generator matrix is:

A four-bit message is represented by a 4-vector p over GF(2). The


encoding of p is the 7-vector resulting from the matrix-vector product
G*p.

Let fG be the encoding function, the function depened by fG(x)=G∗p


The image of fG, the set of all codewords, is the row space of G .
DECODING
Four of the rows of G are the standard basis vectors e1, e2, e3, e4 of
GF(2). It implies that the words are in the codewords.

The matrix-matrix product RG should be the identity matrix


Algorithm:

1. Started
2. we Accepted size of LBC block code in terms n and k
3. We Accepted parity p matrix of size k x (n-k)
4. We Generated generator matrix such that G = [Ik | P] Of size k x
n in which Ik is an identity matrix.
5. We Generated parity check matrix such that H= [PT | In-k] Of
size
(n-k) x n in which PT is an transpose of P matrix.
6. We Generated msg. vector
7. We Generated code vector by formula, C = MG
8. We Displaied it
9. We Also calculated hamming weight of each code word and that is
done by calculating total no.of ones in the code vector. Display it.
10. We Calculated detecting capability by Td =dmin- 1 , where dmin
is minimum hamming distance.
11. We Calculated error correcting capability tc by, tc= (dmin-1) /2
12. we Displaied parity matrix H
13. We calculated syndrome vector for 2 different patterns E.S=E.H
14. We Compared this S with each S created for different error
pattern where S is matched error is in that respective bit w.r.t. the
error pattern. Display no. of bits where is there. If S of received
vector is 0 then display received vector is coorect.

Conclusion:
Code:

Program:
clc;
close all;
n=6;
k=3;
p=[0 1 1 ; 1 0 1; 1 1 0]; % Parity Matrix
d=input('enter three bit message=');
ik=eye(k);
g=cat(2,ik,p);
disp('Generator Matrix:');
disp(g);
c1=mtimes(d,g);
c=mod(c1,2);
disp('The codeword for given message is:');
disp(c);
Results

You might also like