| Communications Toolbox | ![]() |
BCH encoder
code = bchenc(msg,n,k)
code = bchenc(...,paritypos)
code = bchenc(msg,n,k) encodes the message in msg using an [n,k] BCH encoder with the narrow-sense generator polynomial. msg is a Galois array of symbols over GF(2). Each k-element row of msg represents a message word, where the leftmost symbol is the most significant symbol. Parity symbols are at the end of each word in the output Galois array code.
code = bchenc(...,paritypos) specifies whether bchenc appends or prepends the parity symbols to the input message to form code. The string paritypos can be either 'end' or 'beginning'. The default is 'end'.
The tables below list valid [n,k] pairs for small values of n, as well as the corresponding values of the error-correction capability, t.
| n | k | t |
|---|---|---|
| 7 | 4 | 1 |
| n | k | t |
|---|---|---|
| 15 | 11 | 1 |
| 15 | 7 | 2 |
| 15 | 5 | 3 |
| n | k | t |
|---|---|---|
| 31 | 26 | 1 |
| 31 | 21 | 2 |
| 31 | 16 | 3 |
| 31 | 11 | 5 |
| 31 | 6 | 7 |
| n | k | t |
|---|---|---|
| 63 | 57 | 1 |
| 63 | 51 | 2 |
| 63 | 45 | 3 |
| 63 | 39 | 4 |
| 63 | 36 | 5 |
| 63 | 30 | 6 |
| 63 | 24 | 7 |
| 63 | 18 | 10 |
| 63 | 16 | 11 |
| 63 | 10 | 13 |
| 63 | 7 | 15 |
| n | k | t |
|---|---|---|
| 127 | 120 | 1 |
| 127 | 113 | 2 |
| 127 | 106 | 3 |
| 127 | 99 | 4 |
| 127 | 92 | 5 |
| 127 | 85 | 6 |
| 127 | 78 | 7 |
| 127 | 71 | 9 |
| 127 | 64 | 10 |
| 127 | 57 | 11 |
| 127 | 50 | 13 |
| 127 | 43 | 14 |
| 127 | 36 | 15 |
| 127 | 29 | 21 |
| 127 | 22 | 23 |
| 127 | 15 | 27 |
| 127 | 8 | 31 |
| n | k | t |
|---|---|---|
| 255 | 247 | 1 |
| 255 | 239 | 2 |
| 255 | 231 | 3 |
| 255 | 223 | 4 |
| 255 | 215 | 5 |
| 255 | 207 | 6 |
| 255 | 199 | 7 |
| 255 | 191 | 8 |
| 255 | 187 | 9 |
| 255 | 179 | 10 |
| 255 | 171 | 11 |
| 255 | 163 | 12 |
| 255 | 155 | 13 |
| 255 | 147 | 14 |
| 255 | 139 | 15 |
| 255 | 131 | 18 |
| 255 | 123 | 19 |
| 255 | 115 | 21 |
| 255 | 107 | 22 |
| 255 | 99 | 23 |
| 255 | 91 | 25 |
| 255 | 87 | 26 |
| 255 | 79 | 27 |
| 255 | 71 | 29 |
| 255 | 63 | 30 |
| 255 | 55 | 31 |
| 255 | 47 | 42 |
| 255 | 45 | 43 |
| 255 | 37 | 45 |
| 255 | 29 | 47 |
| 255 | 21 | 55 |
| 255 | 13 | 59 |
| 255 | 9 | 63 |
| n | k | t |
|---|---|---|
| 511 | 502 | 1 |
| 511 | 493 | 2 |
| 511 | 484 | 3 |
| 511 | 475 | 4 |
| 511 | 466 | 5 |
| 511 | 457 | 6 |
| 511 | 448 | 7 |
| 511 | 439 | 8 |
| 511 | 430 | 9 |
| 511 | 421 | 10 |
| 511 | 412 | 11 |
| 511 | 403 | 12 |
| 511 | 394 | 13 |
| 511 | 385 | 14 |
| 511 | 376 | 15 |
| 511 | 367 | 16 |
| 511 | 358 | 18 |
| 511 | 349 | 19 |
| 511 | 340 | 20 |
| 511 | 331 | 21 |
| 511 | 322 | 22 |
| 511 | 313 | 23 |
| 511 | 304 | 25 |
| 511 | 295 | 26 |
| 511 | 286 | 27 |
| 511 | 277 | 28 |
| 511 | 268 | 29 |
| 511 | 259 | 30 |
| 511 | 250 | 31 |
| 511 | 241 | 36 |
| 511 | 238 | 37 |
| 511 | 229 | 38 |
| 511 | 220 | 39 |
| 511 | 211 | 41 |
| 511 | 202 | 42 |
| 511 | 193 | 43 |
| 511 | 184 | 45 |
| 511 | 175 | 46 |
| 511 | 166 | 47 |
| 511 | 157 | 51 |
| 511 | 148 | 53 |
| 511 | 139 | 54 |
| 511 | 130 | 55 |
| 511 | 121 | 58 |
| 511 | 112 | 59 |
| 511 | 103 | 61 |
| 511 | 94 | 62 |
| 511 | 85 | 63 |
| 511 | 76 | 85 |
| 511 | 67 | 87 |
| 511 | 58 | 91 |
| 511 | 49 | 93 |
| 511 | 40 | 95 |
| 511 | 31 | 109 |
| 511 | 28 | 111 |
| 511 | 19 | 119 |
| 511 | 10 | 121 |
See the example on the reference page for the function bchdec.
The maximum allowable value of n is 65535.
bchdec, bchgenpoly, Block Coding
| bchdec | bchgenpoly | ![]() |
© 1994-2005 The MathWorks, Inc.