Encodes the message msg using a [n,k] BCH coding. The variable msg is a binary array with k columns and an arbitrary number of rows. Each row of msg represents a single symbol to be coded by the BCH coder. The coded message is returned in the binary array code containing n columns and the same number of rows as msg.
The use of bchenco
can be seen in the following short example.
m = 3; n = 2^m -1; k = 4; msg = randint (10,k); code = bchenco (msg, n, k);
Valid codes can be found using bchpoly
. In general the codeword
length n should be of the form 2^m-1
, where m is an
integer. However, shortened BCH codes can be used such that if
[2^m-1,k]
is a valid code
[2^m-1-x,k-x]
is also a valid code using
the same generator polynomial.
By default the generator polynomial used in the BCH coding is
based on the properties of the Galois Field GF(2^m). This
default generator polynomial can be overridden by a polynomial in g.
Suitable generator polynomials can be constructed with bchpoly
.
By default the parity symbols are placed at the beginning of the coded
message. The variable parpos controls this positioning and can take
the values "beginning"
or "end"
.
See also: bchpoly, bchdeco, encode.
Package: communications