Linear Block Codes
Version 1.0.0 (1.23 KB) by
KARTHIKA M
Generating linear block codes using for loop. This program converts 16 combinations of 4 bit data messages into 7 bit codeword.
H=[1 1 1 0 1 0 0 ;1 1 0 1 0 1 0;1 0 1 1 0 0 1]; %Giving parity check matrix
k=4; %number of inputs
i=0;
n=length(H(1,:)); %length of the codeword
y=(2^k);
I=eye(k); %creating identity matrix
L=H';
X=L((1:k),:); %Extracting parity matrix from H
G=[I X]; %Creating generator matrix
C=zeros(y,n);
%Creating y combinations of k bits (Message bits)
for p=1:y
BC(p,:)=dec2bin(p-1,k);
end
nume=zeros(y,k);
nume=double(BC)-48;
disp(nume);
% Performing encoding
for t=1:y
for j=1:n
for i=1:k
M= (nume(t,i)*G(i,j));
C(t,j)=xor(C(t,j),M);
M=0;
end
end
end
disp(C);
Cite As
KARTHIKA M (2026). Linear Block Codes (https://www.mathworks.com/matlabcentral/fileexchange/173230-linear-block-codes), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2024b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
