| Communications Toolbox | ![]() |
Produce parity-check and generator matrices for cyclic code
Syntax
Description
For all syntaxes, the codeword length is n and the message length is k. A polynomial can generate a cyclic code with codeword length n and message length k if and only if the polynomial is a degree-(n-k) divisor of x^n-1. (Over the binary field GF(2), x^n-1 is the same as x^n+1.) This implies that k equals n minus the degree of the generator polynomial.
h = cyclgen(n,pol)
produces an (n-k)-by-n parity-check matrix for a systematic binary cyclic code having codeword length n. The row vector pol gives the binary coefficients, in order of ascending powers, of the degree-(n-k) generator polynomial.
h = cyclgen(n,pol, is the same as the syntax above, except that the argument opt)
opt determines whether the matrix should be associated with a systematic or nonsystematic code. The values for opt are 'system' and 'nonsys'.
[h,g] = cyclgen(...)
is the same as h = cyclgen(...) except that it also produces the k-by-n generator matrix g that corresponds to the parity-check matrix h.
[h,g,k] = cyclgen(...)
is the same as [h,g] = cyclgen(...) except that it also returns the message length k.
Examples
The code below produces parity-check and generator matrices for a binary cyclic code with codeword length 7 and message length 4.
parmat = 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 1 1 0 1 genmat = 1 0 1 1 0 0 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 k = 4
In the output below, notice that the parity-check matrix is different from parmat above, because it corresponds to a nonsystematic cyclic code. In particular, parmatn does not have a 3-by-3 identity matrix in its leftmost three columns, as parmat does.
See Also
encode, decode, bchpoly, cyclpoly
| cosets | cyclpoly | ![]() |