Main Content

rsenc

Reed-Solomon encoder

Description

code = rsenc(msg,n,k) encodes the message in msg using an [n,k] Reed-Solomon code with the narrow-sense generator polynomial. n is the codeword length and k is the message length. The output code is the Reed-Solomon code.

example

code = rsenc(msg,n,k,genpoly) specifies the generator polynomial for the code.

code = rsenc(___,paritypos) specifies the position of the parity symbols added to the input message to form code.

Examples

collapse all

Set the code parameters.

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

Create two messages based on GF(8).

msg = gf([2 7 3; 4 0 6],m)
 
msg = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)
 
Array elements = 
 
   2   7   3
   4   0   6

Generate RS (7,3) codewords.

code = rsenc(msg,n,k)
 
code = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)
 
Array elements = 
 
   2   7   3   3   6   7   6
   4   0   6   4   2   2   0

The codes are systematic so the first three symbols of each row match the rows of msg.

Input Arguments

collapse all

Input message, specified as a matrix with all values greater than or equal to zero. msg is a Galois array of symbols having m bits each. Each k-element row of msg represents a message word, where 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, rsenc uses a shortened Reed-Solomon 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 that are added to the input message to form code, specified as one of these options.

  • "end" — Appends the parity symbols to the input message.

  • "beginning" — Prepends the parity symbols to the input message.

Data Types: char | string

Output Arguments

collapse all

Reed-Solomon code, returned as a matrix with all values greater than or equal to zero. Parity symbols are at the end of each word in this output Galois array code.

Data Types: double

Version History

Introduced before R2006a