Communications Toolbox    
vitdec

Convolutionally decode binary data using the Viterbi algorithm

Syntax

Description

decoded = vitdec(code,trellis,tblen,opmode,dectype) decodes the vector code using the Viterbi algorithm. The MATLAB structure trellis specifies the convolutional encoder that produced code; the format of trellis is described in Trellis Description of a Convolutional Encoder and the reference page for the istrellis function. code contains one or more symbols, each of which consists of log2(trellis.numOutputSymbols) bits. Each symbol in the vector decoded consists of log2(trellis.numInputSymbols) bits. tblen is a positive integer scalar that specifies the traceback depth.

The string opmode indicates the decoder's operation mode and its assumptions about the corresponding encoder's operation. Choices are in the table below.

Values of opmode Input
Value
Meaning
'trunc'
The encoder is assumed to have started at the all-zeros state. The decoder traces back from the state with the best metric.
'term'
The encoder is assumed to have both started and ended at the all-zeros state. The decoder traces back from the all-zeros state.
'cont'
The encoder is assumed to have started at the all-zeros state. The decoder traces back from the state with the best metric. A delay equal to tblen symbols elapses before the first decoded symbol appears in the output.

The string dectype indicates the type of decision that the decoder makes, and influences the type of data the decoder expects in code. Choices are in the table below.

Values of dectype Input
Value
Meaning
'unquant'
code contains real input values, where 1 represents a logical zero and -1 represents a logical one.
'hard'
code contains binary input values.
'soft'
For soft-decision decoding, use the syntax below. Note that nsdec is required for soft-decision decoding.

Syntax for Soft Decision Decoding

decoded = vitdec(code,trellis,tblen,opmode,'soft',nsdec) decodes the vector code using soft-decision decoding. code consists of integers between 0 and 2^nsdec-1, where 0 represents the most confident 0 and 2^nsdec-1 represents the most confident 1.

Additional Syntaxes for Continuous Operation Mode

decoded = vitdec(...,'cont',...,initmetric,initstates,initinputs) is the same as the earlier syntaxes, except that the decoder starts with its state metrics, traceback states, and traceback inputs specified by initmetric, initstates, and initinputs, respectively. Each real number in initmetric represents the starting state metric of the corresponding state. initstates and initinputs jointly specify the initial traceback memory of the decoder; both are trellis.numStates-by-tblen matrices. initstates consists of integers between 0 and trellis.numStates-1. If the encoder schematic has more than one input stream, then the shift register that receives the first input stream provides the least significant bits in initstates, while the shift register that receives the last input stream provides the most significant bits in initstates. The vector initinputs consists of integers between 0 and trellis.numInputSymbols-1. To use default values for all of the last three arguments, specify them as [],[],[].

[decoded,finalmetric,finalstates,finalinputs] = ...
vitdec(...,'cont',...)
is the same as the earlier syntaxes, except that the final three output arguments return the state metrics, traceback states, and traceback inputs, respectively, at the end of the decoding process. finalmetric is a vector with trellis.numStates elements that correspond to the final state metrics. finalstates and finalinputs are both matrices of size trellis.numStates-by-tblen. The elements of finalstates have the same format as those of initstates.

Examples

The example below encodes random data and adds noise. Then it decodes the noisy code three times to illustrate the three decision types that vitdec supports. Notice that for unquantized and soft decisions, the output of convenc does not have the same data type that vitdec expects for the input code, so it is necessary to manipulate ncode before invoking vitdec.

The example below illustrates how to use the final state and initial state arguments when invoking vitdec repeatedly. Notice that [decoded4;decoded5] is the same as decoded6.

See Also

convenc, poly2trellis, istrellis, vitsimdemo

References

Gitlin, Richard D., Jeremiah F. Hayes, and Stephen B. Weinstein, Data Communications Principles, New York, Plenum, 1992.


  vec2mat wgn