Communications Toolbox    

Creating and Decoding Reed-Solomon Codes

The rsenc and rsdec functions create and decode Reed-Solomon codes, using the data described in Representing Words for Reed-Solomon Codes and Parameters for Reed-Solomon Codes.

This section illustrates how to use rsenc and rsdec. The topics are

Example: Reed-Solomon Coding Syntaxes

The example below illustrates multiple ways to encode and decode data using a [15,13] Reed-Solomon code. The example shows that you can

The example also shows that corresponding syntaxes of rsenc and rsdec use the same input arguments, except for the first input argument.

Example: Detecting and Correcting Errors

The example below illustrates the decoding results for a corrupted code. The example encodes some data, introduces errors in each codeword, and invokes rsdec to attempt to decode the noisy code. It uses additional output arguments in rsdec to gain information about the success of the decoding process.

Notice that the array of noise values contains integers between 1 and 2^m, and that the addition operation c + noise takes place in the Galois field GF(2^m) because c is a Galois array in GF(2^m).

The output from the example is below. The nonzero value of ans indicates that the decoder was able to correct the corrupted codewords and recover the original message. The values in the vector nerrs indicates that the decoder corrected t errors in each codeword.

Excessive Noise in Reed-Solomon Codewords

In the previous example, rsdec corrected all of the errors. However, each Reed-Solomon code has a finite error-correction capability. If the noise is so great that the corrupted codeword is too far in Hamming distance from the correct codeword, then either

In both cases, the decoder returns the wrong message. However, you can tell when a decoding failure occurs because rsdec also returns a value of -1 in its second output.

To examine cases in which codewords are too noisy for successful decoding, change the previous example so that the definition of noise is

Creating Shortened Reed-Solomon Codes

Every Reed-Solomon encoder uses a codeword length that equals 2m-1 for an integer m. A shortened Reed-Solomon code is one in which the codeword length is not 2m-1. A shortened [n,k] Reed-Solomon code implicitly uses an [n1,k1] encoder, where

The rsenc and rsdec functions support shortened codes using the same syntaxes that they use for nonshortened codes. You do not need to indicate explicitly that you want to use a shortened code. For example, compare the two similar-looking commands below. The first creates a (nonshortened) [7,5] code. The second causes rsenc to create a [5,3] shortened code by implicitly using a [7,5] encoder.

How rsenc Creates a Shortened Code.   When creating a shortened code, rsenc performs these steps:

The example below illustrates this process. Note that forming a [12,8] Reed-Solomon code actually uses a [15,11] Reed-Solomon encoder. Also note that you do not have to indicate in the rsenc syntax that this is a shortened code or that the proper encoder to use is [15,11].


  Parameters for Reed-Solomon Codes Selected Bibliography for Block Coding