DSPRelated.com
Code

Repetition code

Senthilkumar March 28, 2012 Coded in Scilab

This program is used to generate repetition code for the following specifications: number of bits =5, message bit value =1

function [G,H,x]=RepetitionCode(n,k,m)

//Repetition Codes
//n =block of identical 'n' bits
//k =1 one bit
//m = 1;// bit value = 1
I = eye(n-k,n-k);//Identity matrix
P = ones(1,n-k);//coefficient matrix
H = [I P'];//parity-check matrix
G = [P 1];//generator matrix 
x = m.*G; //code word
disp(G,'generator matrix');
disp(H,'parity-check matrix');
disp(x,'code word for binary one input');
endfunction
//Result
//-->exec('C:\Users\SENTHILKUMAR\Desktop\Communication_Toolbox\Digital_Communication\RepetitionCode.sci', -1)
// 
//-->n = 5
// n  =
// 
//    5.  
// 
//-->k =1
// k  =
// 
//    1.  
// 
//-->m =1
// m  =
// 
//    1.  
// 
//-->[G,H,x]=RepetitionCode(n,k,m)
// 
// generator matrix   
// 
//    1.    1.    1.    1.    1.  
// 
// parity-check matrix   
// 
//    1.    0.    0.    0.    1.  
//    0.    1.    0.    0.    1.  
//    0.    0.    1.    0.    1.  
//    0.    0.    0.    1.    1.  
// 
// code word for binary one input   
// 
//    1.    1.    1.    1.    1.  
// x  =
// 
//    1.    1.    1.    1.    1.  
// H  =
// 
//    1.    0.    0.    0.    1.  
//    0.    1.    0.    0.    1.  
//    0.    0.    1.    0.    1.  
//    0.    0.    0.    1.    1.  
// G  =
// 
//    1.    1.    1.    1.    1.