Error-Control Coding

You can use this toolbox to perform block error-control coding and convolution error-control coding computations. The toolbox contains a SIMULINK Error-Control Coding Library, which can be further divided into the following sublibraries:
Hamming Code
BCH Code
Reed-Solomon Code
Cyclic Code
Linear Block Code
Convolution Code

You can view a list of all SIMULINK blocks in the Error-Control Coding category.

There are two major MATLAB functions for error-control coding computation:

encode - Encode computation for error-control coding methods.
decode - Decode computation for error-control coding methods.

There are some other supporting functions in this category:

rsencof - Encode a text file using Reed-Solomon code.
rsdecof - Decode a Reed-Solomon code encoded text file.
bchpoly - BCH code generator polynomial.
cyclgen - Cyclic code generator and parity-check matrices.
cyclpoly - Cyclic generator polynomial.
gen2par - Generator matrix to parity-check matrix conversion.
hammgen - Hamming code generator and parity-check matrices.
htruthtb - Truth table from generator or parity check matrix.
oct2gen - Convolution code octal form to binary form conversion.
sim2gen - Convolution code binary from SIMULINK block diagram.

The following four examples show how to use the toolbox for error-control coding computation.

Example 1: Using Reed-Solomon Code (RS) for text file error-control coding.

This example codes a ASCII text file using Reed-Solomon code. The example generates a figure showing the stages of the text files. The original text shows at the top-left corner. The coded file shows at the top right corner. Assume some errors will occur in the data transmission or storage. The text with error shows at the bottom-right of the figure. Note that all $$ signs are errors added to the file. The RS decode takes the file with noise and outputs the decoded file at the bottom-left of the figure. The simulation uses the commands:
% encode
rsencof rstemp.tst temp.cod
% add noise.
fid = fopen('temp.cod', 'r');
x = fread(fid, inf, 'char');
fclose(fid);
for i = 30 : 65 : length(x)
x(i:i+1) = abs('$$');
end;
fid = fopen('temp.noi','w');
fwrite(fid, x, 'char');
decode
rsdecofrsdecof temp.noi temp.dec
You can edit the file temp.cod to see the decode result. Note that you can change the characters in the file. You cannot, however, add or delete characters. Use the following command to recover the text.
rsdecof temp.noi temp.dec

Example 2: Using BCH code SIMULINK block

Start the simulation for a 30 second simulation.
This simulation generates an error-rate meter figure. The left side of the meter shows the symbols transfered from the source. The right side of the meter shows the recovered symbols. The number of symbol/bit, symbol/bit error number, and symbol/bit error rates shows at the bottom of the error rate meter.

Example 3: Using SIMULINK block diagram to construct a transfer function for convolution code.

The block diagram contains four different blocks: Memory, XOR, Inport, and Outport. You can change the block diagram structure and then click here for new transfer functions that show at the MATLAB prompt.

Example 4: Convolution code with trellis using SIMULINK block diagram.

Start the simulation for a 15 second simulation.
The trellis figure generated from the simulation shows the convolution code decision path. The red path is the decision path. The yellow paths are the survivors. The green circles are the possible states.

Return to the first page of the tutorial
Return to the functionality listing

This is hcomcode.html file.