Main Content

rsdec

Reed-Solomon decoder

Description

example

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. n is the codeword length and k is the message length. Output decoded is the decoded Reed-Solomon encoded signal.

decoded = rsdec(code,n,k,genpoly) specifies the generator polynomial for the code for a nonzero value.

decoded = rsdec(___,paritypos) specifies the position of the parity symbols in code.

[decoded,cnumerr] = rsdec(___) also returns the number of corrected errors as a column vector.

[decoded,cnumerr,ccode] = rsdec(___) additionally returns the corrected version of code.

Examples

collapse all

Set the RS code parameters.

m = 3;                   % Number of bits per symbol
n = 2^m-1;               % Codeword length
k = 3;                   % Message length

Generate three codewords composed of 3-bit symbols. Encode the message with a (7,3) RS code.

msg = gf([2 7 3; 4 0 6; 5 1 1],m);
code = rsenc(msg,n,k);

Introduce one error on the first codeword, two errors on the second codeword, and three errors on the third codeword.

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;

Decode the corrupted codeword.

[rxcode,cnumerr] = rsdec(noisycode,n,k);

Observe that the number of corrected errors matches the introduced errors for the first two rows. In row three, the number of corrected errors is -1 because a (7,3) RS code cannot correct more than two errors.

cnumerr
cnumerr = 3×1

     1
     2
    -1

Input Arguments

collapse all

Received corrupted Reed-solomon encoded codeword, specified as a matrix with all values greater than or equal to zero. 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.

Data Types: double

Codeword length, specified as an integer of the form 2m–1, where m is in the range [3, 16]. n must be in the range [7, 65535].

If n is not exactly 2m-1, rsdec assumes that code is a corrupted version of a shortened code.

Note

n and k must differ by a positive even integer.

Data Types: double

Message length, specified as a positive integer.

Data Types: double

Generator polynomial coefficients in descending order, returned as a Galois row vector. genpoly represents the coefficients of the narrow-sense generator polynomial in order of descending powers. To use the default narrow-sense generator polynomial, set genpoly to [].

The generator polynomial must have degree of n-k.

Data Types: double

Indicates position of the parity symbols in code, specified as one of these options.

  • "end" — Appends the parity symbols to the input message in the coding operation to form code.

  • "beginning" — Prepends the parity symbols to the input message in the coding operation to form code.

Data Types: double

Output Arguments

collapse all

Decoded Reed-Solomon encoded signal, returned as a matrix. Each row of the matrix represents the attempt at decoding the corresponding row in code.

A decoding failure occurs if rsdec detects more than (n-k)/2 errors in a row of code. In this case, rsdec forms the corresponding row of decoded by merely removing n-k symbols from the end of the row of code. If you set the paritypos argument to "beginning", a decoding failure causes rsdec to remove n-k symbols from the beginning rather than the end of the row.

Data Types: double

Number of corrected errors, returned as a column vector. Each element of this vector represents the corrected errors in the corresponding row of code.

A value of -1 indicates a decoding failure in that row in code.

Data Types: double

Corrected version of input code code, returned as a matrix with all values greater than or equal to zero. ccode is a Galois array that has the same format as code.

If a decoding failure occurs in a certain row of code, the corresponding row in ccode contains that row unchanged.

Data Types: double

Algorithms

rsdec uses the Berlekamp-Massey decoding algorithm. For information about this algorithm, see the works in References.

References

[1] Wicker, S. B., Error Control Systems for Digital Communication and Storage, Upper Saddle River, NJ, Prentice Hall, 1995.

[2] Berlekamp, E. R., Algebraic Coding Theory, New York, McGraw-Hill, 1968.

Version History

Introduced before R2006a

See Also

Functions

Objects