Performing Other Block Code Tasks

This section describes functions that compute typical parameters associated with linear block codes, as well as functions that convert information from one format to another. The topics are

Finding a Generator Polynomial

To find a generator polynomial for a cyclic, BCH, or Reed-Solomon code, use the cyclpoly, bchgenpoly, or rsgenpoly function, respectively. The commands

genpolyCyclic = cyclpoly(15,5) % 1+X^5+X^10
genpolyBCH = bchgenpoly(15,5)  % x^10+x^8+x^5+x^4+x^2+x+1
genpolyRS = rsgenpoly(15,5)

find generator polynomials for block codes of different types. The output is below.

genpolyCyclic =

     1     0     0     0     0     1     0     0     0     0     1

 
genpolyBCH = GF(2) array. 
 
Array elements = 
 
     1     0     1     0     0     1     1     0     1     1     1

 
genpolyRS = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)
 
Array elements = 
 
     1     4     8    10    12     9     4     2    12     2     7

The formats of these outputs vary:

Nonuniqueness of Generator Polynomials.   Some pairs of message length and codeword length do not uniquely determine the generator polynomial. The syntaxes for functions in the example above also include options for retrieving generator polynomials that satisfy certain constraints that you specify. See the functions' reference pages for details about syntax options.

Algebraic Expression for Generator Polynomials.   The generator polynomials produced by bchgenpoly and rsgenpoly have the form (X - Ab)(X - Ab+1)...(X - Ab+2t-1), where A is a primitive element for an appropriate Galois field, and b and t are integers. See the functions' reference pages for more information about this expression.

Finding the Error-Correction Capability

The bchgenpoly and rsgenpoly functions can return an optional second output argument that indicates the error-correction capability of a BCH or Reed-Solomon code. For example, the commands

[g,t] = bchgenpoly(31,16);
t
t =

     3

find that a [31, 16] BCH code can correct up to 3 errors in each codeword.

Finding Generator and Parity-Check Matrices

To find a parity-check and generator matrix for a Hamming code with codeword length 2^m-1, use the hammgen function as below. m must be at least three.

[parmat,genmat] = hammgen(m); % Hamming

To find a parity-check and generator matrix for a cyclic code, use the cyclgen function. You must provide the codeword length and a valid generator polynomial. You can use the cyclpoly function to produce one possible generator polynomial after you provide the codeword length and message length. For example,

[parmat,genmat] = cyclgen(7,cyclpoly(7,4)); % Cyclic

Converting Between Parity-Check and Generator Matrices

The gen2par function converts a generator matrix into a parity-check matrix, and vice versa. Examples to illustrate this are on the reference page for gen2par.


© 1994-2005 The MathWorks, Inc.