Loadable Function: msg = bchdeco (code, k, t)
Loadable Function: msg = bchdeco (code, k, t, prim)
Loadable Function: msg = bchdeco (…, parpos)
Loadable Function: [msg, err] = bchdeco (…)
Loadable Function: [msg, err, ccode] = bchdeco (…)

Decodes the coded message code using a BCH coder. The message length of the coder is defined in variable k, and the error correction capability of the code is defined in t.

The variable code is a binary array with n columns and an arbitrary number of rows. Each row of code represents a single symbol to be decoded by the BCH coder. The decoded message is returned in the binary array msg containing k columns and the same number of rows as code.

The use of bchdeco can be seen in the following short example.

m = 3; n = 2^m -1; k = 4; t = 1;
msg = randint (10, k);
code = bchenco (msg, n, k);
noisy = mod (randerr (10,n) + code, 2);
[dec, err] = bchdeco (msg, k, t);

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 BCH coding is based on the properties of the Galois Field GF(2^m). The primitive polynomial used in the Galois can be overridden by a primitive polynomial in prim. Suitable primitive polynomials can be constructed with primpoly. The form of prim maybe be either a integer representation of the primitive polynomial as given by primpoly, or a binary representation that might be constructed like

m = 3;
prim = de2bi (primpoly (m));

By default the parity symbols are assumed to be 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, bchenco, decode, primpoly.

Package: communications