| Communications Toolbox | ![]() |
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
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:
cyclpoly represents a generator polynomial using an integer row vector that lists the polynomial's coefficients in order of ascending powers of the variable.
bchgenpoly and rsgenpoly represent a generator polynomial using a Galois row vector that lists the polynomial's coefficients in order of descending powers of the variable.
rsgenpoly uses coefficients in a Galois field other than the binary field GF(2). For more information on the meaning of these coefficients, see How Integers Correspond to Galois Field Elements and Polynomials over Galois Fields.
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.
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.
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
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.
| Creating and Decoding Linear Block Codes | Selected Bibliography for Block Coding | ![]() |
© 1994-2005 The MathWorks, Inc.