0% found this document useful (0 votes)
3 views1 page

Cs 12 Code

The document outlines a process for encoding and decoding messages using a generator matrix for a linear block code. It includes the creation of a message table, codeword table, and a parity check matrix, as well as the calculation of syndromes to detect and correct errors in received codewords. The example demonstrates the transmission of a codeword and the correction of errors based on the received codeword and the defined syndrome list.

Uploaded by

24l160
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Cs 12 Code

The document outlines a process for encoding and decoding messages using a generator matrix for a linear block code. It includes the creation of a message table, codeword table, and a parity check matrix, as well as the calculation of syndromes to detect and correct errors in received codewords. The example demonstrates the transmission of a codeword and the correction of errors based on the received codeword and the defined syndrome list.

Uploaded by

24l160
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

clc;clear;close all;

G=[1 0 0 0 1 0 1;0 1 0 0 1 1 1;0 0 1 0 1 1 0 ;0 0 0 1 0 1 1];


k=4;n=7;
disp('Generator matrix'); disp(G);
msg_table=dec2bin(0:2^k-1)-48;
disp('Message table');
disp(msg_table);
cw_table=mod(msg_table*G,2);
disp('Codeword table');
disp(cw_table);
msg_tx=[0 1 1 0];
cw_tx=mod(msg_tx*G,2);
disp('Codeword to be transmitted');
disp(cw_tx);
%Reciever side
cw_rx=[0 1 1 0 1 0 1];
disp('Codeword recieved');
disp(cw_rx);
H=[G(:,5:7)' eye(n-k)]; %(all row,5 to 7 column),eye=identity
matrix
disp('Parity check matrix');
disp(H);
error_pattern=[zeros(1,n);eye(n)]; %first row all zeros then
7x7 identity matrix
disp('Error pattern');
disp(error_pattern);
syn_list=[zeros(1,n-k);H']; %syndrome is h transpose,add zeros
at first line to avoid error
disp('Syndrome list');
disp(syn_list);
syndrome=mod(cw_rx*H',2);
disp('Syndrome');
disp(syndrome);
for i=1:n+1
if(syndrome==syn_list(i,:)) %if any row in synlist=syndrome,
then the row number's bit in recieved codeword has error.(if
5th row, then 5th bit error)
break;
end
end
corrected_cw=mod(cw_rx+error_pattern(i,:),2);
disp('Corrected codeword');
disp(corrected_cw);

You might also like