Communications Toolbox | ![]() ![]() |
Produce parameters or generator polynomial for binary BCH code
Syntax
bchpoly params = bchpoly params = bchpoly(n); genpoly = bchpoly(n,k); genpoly = bchpoly(prim_poly,k); [genpoly,factors] = bchpoly(...,k); [genpoly,factors,cst] = bchpoly(...,k); [genpoly,factors,cst,h] = bchpoly(...,k); [genpoly,factors,cst,h,t] = bchpoly(...,k);
Description
bchpoly
produces a figure window containing a table that lists valid codeword and message lengths of binary BCH codes, as well as the corresponding error-correction capabilities. The codeword lengths listed are 7, 15, 31, 63, 127, 255, and 511. The codeword lengths, message length, and error-correction capabilities are denoted by N, K, and T, respectively.
params = bchpoly
produces a three-column matrix containing the same information that is in the table mentioned in the syntax above. The first column of params
gives the codeword length, the second column gives the message length, and the third column gives the error-correction capability.
params = bchpoly(n)
produces a matrix params
containing valid codeword and message lengths of binary BCH codes in its first and second columns, respectively. If n
< 1024, then params
has a third column that lists the corresponding error-correction capabilities. The codeword lengths listed in the first column of params
are all equal to max(7,2^ceil(log2(n+1))-1)
. This expression gives the smallest number of the form 2m-1 that is at least as big as n
, where m is an integer greater than or equal to 3.
genpoly = bchpoly(n,k)
produces a generator polynomial for a binary BCH code having codeword length n
and message length k
. genpoly
is a row vector that gives the coefficients, in order of ascending powers, of the generator polynomial. n
must have the form 2m-1 for some integer m greater than or equal to 3. k
must be a valid message length, as reported in the second column of the output of the command genpoly = bchpoly(n)
. The primitive polynomial used for the GF(2m) calculations is the default primitive polynomial, gfprimdf
(m).
genpoly = bchpoly(prim_poly,k)
produces a generator polynomial for a binary BCH code having codeword length n and message length k
. prim_poly
represents a degree-m primitive polynomial for the field GF(2m). Both prim_poly
and genpoly
are row vectors that represent polynomials by giving the coefficients in order of ascending powers. Given the degree m of the primitive polynomial, the message length n is 2m-1. k
must be a valid message length, as reported in the second column of the output of the command genpoly = bchpoly(
n)
.
The remaining syntaxes, of the form
return some or all of the output variables listed in the table below.
Output Variable |
Significance |
Format |
factors |
Irreducible factors of the generator polynomial |
Binary matrix, each row of which gives the coefficients of a factor polynomial in order of ascending powers |
cst |
Cyclotomic cosets of the field GF(2m) |
Same as gfcosets (m) |
h |
Parity-check matrix of the code |
(n -k )-by-n binary matrix |
t |
Error-correction capability of the code |
Positive integer |
Examples
The script below uses bchpoly
to find out what message lengths are valid for a BCH code with codeword length 24-1. It then chooses one of the possible message lengths and uses bchpoly
to find the generator polynomial and parity-check matrix for such a code.
m = 4; n = 2^m-1; % Codeword length is 15. % Want to find out possible valid message lengths. params = bchpoly(n); disp(['Possible message lengths are ',num2str(params(:,2)')]) disp(' ') ii = 1; % Arbitrarily choose first row. k = params(ii,2); % Message lengths are in 2nd column. % Get generator polynomial and other facts. [genpoly,factors,cst,parmat,errorcorr] = bchpoly(n,k); disp(['For k = ',num2str(k),' the generator polynomial is']) gfpretty(genpoly) disp('and the parity-check matrix is') parmat
Possible message lengths are 11 7 5 For k = 11 the generator polynomial is 4 1 + X + X and the parity-check matrix is parmat = Columns 1 through 12 1 0 0 0 1 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 1 0 0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 0 0 1 1 0 1 0 1 Columns 13 through 15 1 1 1 1 0 0 1 1 0 1 1 1
See Also
cyclpoly
, encode
, decode
References
Peterson, W. Wesley, and E. J. Weldon, Jr., Error-correcting Codes, 2nd ed., Cambridge, Mass., MIT Press, 1972.
![]() | bchenco | bi2de | ![]() |