Documentation

rsenc

Reed-Solomon encoder

Syntax

code = rsenc(msg,n,k)
code = rsenc(msg,n,k,genpoly)
code = rsenc(...,paritypos)

Description

code = rsenc(msg,n,k) encodes the message in msg using an [n,k] Reed-Solomon code with the narrow-sense generator polynomial. 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. n is at most 2m-1. If n is not exactly 2m-1, rsenc uses a shortened Reed-Solomon code. Parity symbols are at the end of each word in the output Galois array code.

code = rsenc(msg,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 [].

code = rsenc(...,paritypos) specifies whether rsenc 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'.

Examples

collapse all

Reed-Solomon Code Generation

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 = 
 
  Columns 1 through 6

           2           7           3           3           6           7
           4           0           6           4           2           2

  Column 7

           6
           0

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

Limitations

n and k must differ by an integer. n between 7 and 65535.

See Also

| |

Introduced before R2006a

Was this topic helpful?