Linear Block Codes

Generating linear block codes using for loop. This program converts 16 combinations of 4 bit data messages into 7 bit codeword.

You are now following this Submission

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://ch.mathworks.com/matlabcentral/fileexchange/173230-linear-block-codes), MATLAB Central File Exchange. Retrieved .

Tags

Add Tags

Add the first tag.

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0