msg = decode(code,n,k)
decodes the coded message code. The function assumes that the Hamming
encoding method was used, with codeword length n and message length
k.
msg = decode(code,n,k,codingMethod,prim_poly)
decodes code assuming that prim_poly is the
primitive polynomial used for encoding. This syntax applies when
codingMethod is 'hamming/binary' or
'hamming/decimal'.
msg = decode(code,n,k,codingMethod,genmat)
decodes code assuming that genmat is the
generator matrix used for encoding. This syntax applies when
codingMethod is 'linear/binary' or
'linear/decimal'.
msg = decode(code,n,k,codingMethod,genmat,trt)
additionally specifies the decoding table trt. This syntax applies when
codingMethod is 'linear/binary' or
'linear/decimal'.
msg = decode(code,n,k,codingMethod,genpoly)
decodes code assuming that genpoly is the
generator polynomial used for encoding. This syntax applies when
codingMethod is 'cyclic/binary' or
'cyclic/decimal'.
msg = decode(code,n,k,codingMethod,genpoly,trt)
additionally specifies the decoding table trt. This syntax applies when
codingMethod is 'cyclic/binary' or
'cyclic/decimal'.
[msg,err,ccode,cerr] = decode(___)
additionally returns the message word errors err, the corrected
codeword ccode, and the codeword errors cerr,
using any input argument combination from the previous syntaxes.
Column or row vector of integers in the range [0,
2n–1]
Data Types: single | double
n — Codeword length positive integer
Codeword length, specified as a positive integer. The function calculates this value
as 2m–1, where
m is an integer greater than or equal to 2.
k — Message length positive integer
Message length, specified as a positive integer. The function calculates this value
as n–m, where m must be
greater than or equal to 2.
codingMethod — Error coding method and format 'hamming/binary' (default) | 'hamming/decimal' | 'linear/binary' | ...
Error coding method and format, specified as one of these options:
'hamming/binary'
'hamming/decimal'
'linear/binary'
'linear/decimal'
'cyclic/binary'
'cyclic/decimal'
The value you choose for this input determines the syntax you must use. This table
summarizes the dependency. The table does not cover the first syntax because you do not
specify a value for codingMethod when you use it.
Generator polynomial, specified as a polynomial character vector or a
row vector that gives the coefficients in order of ascending powers of the binary
generator polynomial. The value of genpoly for an
[n, k] cyclic code must have degree
n–k and divide
xn–1, where
x is an identifier.
Dependencies
This argument applies when you set CodingMethod to
'cyclic/binary' or 'cyclic/decimal'.
Data Types: double | char | string
trt — Decoding table binary matrix
Decoding table, specified as a
2n-k-by-n binary
matrix. Create the decoding table using the syndtable function.
Dependencies
This argument applies when you set CodingMethod to
'linear/binary', 'linear/decimal',
'cyclic/binary', or 'cyclic/decimal'.
msg — Decoded messages binary column or row vector | binary matrix with k columns | column or row vector of integers in the range [0,
2k–1].
Decoded messages, returned as one
of the options in the table. The value and dimension of msg depends
on the value and dimension of code and the
input message format.
column or row vector of integers in the range [0,
2n–1]
decimal
column or row vector of integers in the range [0,
2k–1]
Data Types: single | double
err — Message error correction information column vector of integers
Message error correction information, returned as a column vector of integers. The
length of the vector is equal to the number of message words. The vector entries can
take these values:
0 — The function did not detect an error in the
corresponding message word.
1 — The function detected and corrected an error in the
corresponding message word.
–1 — The decoding algorithm detected more errors in the
corresponding message word than could be corrected.
ccode — Corrected code binary column or row vector | binary matrix with n columns | column or row vector of integers in the range [0,
2n–1].
cerr — Codeword error correction information column vector of integers
Codeword error correction information, returned as a column vector of integers. The
length of the vector is equal to the number of message words. The meaning of this output
depends on the format of code. If
code is not a binary vector, cerr is equal
to err. If code is a binary vector, this
output contains error detection information for codewords. The information is given in
the same way as in err.
Algorithms
Depending on the decoding method, decode relies on lower-level functions
such as hammgen, syndtable, and cyclgen.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.