Communications Toolbox | ![]() ![]() |
Syntax
decoded = rsdec(code,n,k)
decoded = rsdec(code,n,k,genpoly)
decoded = rsdec(...,paritypos
)
[decoded,cnumerr] = rsdec(...)
[decoded,cnumerr,ccode] = rsdec(...)
Description
decoded = rsdec(code,n,k)
attempts to decode the received signal in code
using an [n
,k
] Reed-Solomon decoding process with the narrow-sense generator polynomial. code
is a Galois array of symbols having m bits each. Each n
-element row of code
represents a corrupted systematic codeword, where the parity symbols are at the end and the leftmost symbol is the most significant symbol. n
is at most 2m-1. If n
is not exactly 2m-1, then rsdec
assumes that code
is a corrupted version of a shortened code.
In the Galois array decoded
, each row represents the attempt at decoding the corresponding row in code
. A decoding failure occurs if a row of code
contains more than (n-k)/2
errors. In this case, rsdec
forms the corresponding row of decoded
by merely removing n-k
symbols from the end of the row of code
.
decoded = rsdec(code,n,k,genpoly)
is the same as the syntax above, except that a nonempty value of genpoly
specifies the generator polynomial for the code. In this case, genpoly
is a Galois row vector that lists the coefficients, in order of descending powers, of the generator polynomial. The generator polynomial must have degree n-k
. To use the default narrow-sense generator polynomial, set genpoly
to []
.
decoded = rsdec(...,
specifies whether paritypos
)
rsdec
appends or prepends the parity symbols to the input message to form decoded
. The string paritypos
can be either 'end'
or 'beginning'
. The default is 'end'
. If paritypos
is 'beginning'
, then a decoding failure causes rsdec
to remove n-k
symbols from the beginning rather than the end of the row.
[decoded,cnumerr] = rsdec(...)
returns a column vector cnumerr
, each element of which is the number of corrected errors in the corresponding row of code
. A value of -1
in cnumerr
indicates a decoding failure in that row in code
.
[decoded,cnumerr,ccode] = rsdec(...)
returns ccode
, the corrected version of code
. The Galois array ccode
has the same format as code
. If a decoding failure occurs in a certain row of code
, then the corresponding row in ccode
contains that row unchanged.
Examples
The example below encodes three message words using a (7,3) Reed-Solomon encoder. It then corrupts the code by introducing one error in the first code word, two errors in the second code word, and three errors in the third code word. Then rsdec
tries to decode the corrupted code.
m = 3; % Number of bits per symbol n = 2^m-1; k = 3; % Word lengths for code msg = gf([2 7 3; 4 0 6; 5 1 1],m); % Three rows of m-bit symbols code = rsenc(msg,n,k); errors = gf([2 0 0 0 0 0 0; 3 4 0 0 0 0 0; 5 6 7 0 0 0 0],m); noisycode = code + errors; [dec,cnumerr] = rsdec(noisycode,n,k) dec = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 2 7 3 4 0 6 4 0 0 cnumerr = 1 2 -1
The output shows that rsdec
successfully corrects the errors in the first two code words and recovers the first two original message words. However, a (7,3) Reed-Solomon code can correct at most two errors in each word, so rsdec
cannot recover the third message word. The elements of the vector cnumerr
indicate the number of corrected errors in the first two words and also indicate the decoding failure in the third word.
For additional examples, see Creating and Decoding Reed-Solomon Codes.
Algorithm
rsdec
uses the Berlekamp-Massey decoding algorithm. For information about this algorithm, see the works listed in References below.
Limitations
n
and k
must differ by an even integer. The maximum allowable value of n
is 65535.
See Also
References
[1] Wicker, Stephen B., Error Control Systems for Digital Communication and Storage, Upper Saddle River, N.J., Prentice Hall, 1995.
[2] Berlekamp, Elwyn R., Algebraic Coding Theory, New York, McGraw-Hill, 1968.
![]() | rcosine | rsdecof | ![]() |