| Communications Toolbox | ![]() |
Syntax
msg = rsdeco(code,n,k);
msg = rsdeco(code,n,k,format);
msg = rsdeco(code,field,...);
[msg,err] = rsdeco(...);
[msg,err,ccode] = rsdeco(...);
[msg,err,ccode,cerr] = rsdeco(...);
For All Syntaxes
The encoding counterpart for this function is rsenco.
In all cases, the codeword length n must have the form 2m-1 where m is an integer greater than or equal to 3.
The matrix code, which contains the code words to be decoded, can have one of several formats. The table below shows the formats for msg, how the optional argument format should reflect the format of msg, and how the format of the output code depends on these choices. If format is not specified as input, then its default value is binary.
For Specific Syntaxes
msg = rsdeco(code,n,k)
decodes code using the Reed-Solomon decoding method. n is the codeword length and k is the message length. code has either of the two binary formats described in Table 3-20, Information Formats for Reed-Solomon Decoding.
msg = rsdeco(code,n,k, is the same as the syntax above, except that format)
format specifies the format of code. Table 3-20, Information Formats for Reed-Solomon Decoding, lists the possible values for format, as well as the corresponding shape and contents of code.
msg = rsdeco(code,field,...)
is a faster variation of the syntaxes above. field is a matrix that lists all elements of GF(2m) in the format described in List of All Elements of a Galois Field. The size of field determines n.
[msg,err] = rsdeco(...)
outputs the number err, which specifies the number of errors that occurred in the decoding.
[msg,err,ccode] = rsdeco(...)
outputs ccode, a corrected version of code. The format of ccode matches the format of code in the input.
[msg,err,ccode,cerr] = rsdeco(...)
outputs the number cerr, which specifies the number of errors found in the ccode column.
Examples
This example creates and decodes a noisy code. Although some codewords contain errors, the decoded message contains no errors.
L = 1000; % Number of bits in the computation
m = 4;
n = 2^m - 1; % Codeword length
k = n - 4; % Message word length
rand('state',9876); % Initialize random number generator.
msg = randint(L,1); % L bits of data
field = gftuple([-1 : n-1]',m); % List of elements in GF(2^m)
[code,added] = rsenco(msg,field,k); % Encode the data.
msg = [msg; zeros(added,1)]; % Pad msg for later comparison.
% Add burst errors of length m to the code.
noi = rand(length(code)/m,1) < .03; % Three percent noise
noi = (noi*ones(1,m))'; noi = noi(:);
code_noi = rem(code + noi,2);
% Decode the noisy code.
[dec,err,ccode,err_c] = rsdeco(code_noi,field,k);
err_c = reshape(err_c,n,length(err_c)/n)';
% Number of code symbols that contain at least one error
num_err_codesyms = sum(err_c(:,1) > 0)
% Number of bit errors after decoding
num_err_decbits = sum(abs(dec-msg))
num_err_codesyms =
36
num_err_decbits =
0
See Also
rsenco, rsdecode, rspoly, encode, decode
| rcosine | rsdecode | ![]() |