Digital (Exp - 11)
Digital (Exp - 11)
Aim:
To study encoding and decoding of linear block codes.
Theory:
Linear block codes are a category of error-correcting codes commonly used in digital communication systems. A
linear block code is denoted as (n, k), where k represents the number of data bits and n is the total number of bits
The (7,4) Hamming Code is a classic example that takes 4 data bits and encodes them into 7-bit codewords
by appending 3 parity bits. It has the capability to detect up to two-bit errors and correct one-bit errors.
Encoding is performed using a Generator Matrix (G), and decoding uses a Parity-Check Matrix (H) to compute
the syndrome. The syndrome helps to identify and correct the position of any single-bit error in the codeword.
MATLAB Code:
clc;
clear;
% Parity-check matrix H
H = [1 1 0 1 1 0 0;
1 0 1 1 0 1 0;
0 1 1 1 0 0 1];
% Encoding
codeword = mod(msg * G, 2);
disp('Encoded Codeword:');
disp(codeword);
% Syndrome calculation
syndrome = mod(H * received', 2);
disp('Syndrome:');
disp(syndrome');
Output:
Encoded Codeword:
1 0 1 1 0 0 1
Syndrome:
1 1 0
Corrected Codeword:
1 0 1 1 0 0 1
Decoded Message:
1 0 1 1
Observations:
- The encoded 7-bit codeword correctly incorporates parity for error detection and correction.
- The error was successfully corrected, and the original message was accurately retrieved.
Conclusion:
The (7,4) Hamming Code effectively encodes 4-bit messages into 7-bit codewords, allowing for single-bit
error correction. Using generator and parity-check matrices in MATLAB, the experiment demonstrates