Communications Toolbox    
convenc

Convolutionally encode binary data

Syntax

Description

code = convenc(msg,trellis) encodes the binary vector msg using the convolutional encoder whose MATLAB trellis structure is trellis. For details about MATLAB trellis structures, see Trellis Description of a Convolutional Encoder. Each symbol in msg consists of log2(trellis.numInputSymbols) bits. The vector msg contains one or more symbols. The output vector code contains one or more symbols, each of which consists of log2(trellis.numOutputSymbols) bits.

code = convenc(msg,trellis,initstate) is the same as the syntax above, except that initstate specifies the starting state of the encoder registers. The scalar initstate is an integer 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 initstate, while the shift register that receives the last input stream provides the most significant bits in initstate. To use the default value for initstate, specify initstate as 0 or [].

[code,finalstate] = convenc(...) encodes the input message and also returns in finalstate the encoder's state. finalstate has the same format as initstate.

Examples

The command below encodes five two-bit symbols using a rate 2/3 convolutional code. A schematic of this encoder is on the reference page for the poly2trellis function.

The commands below define the encoder's trellis structure explicitly and then use convenc to encode ten one-bit symbols. A schematic of this encoder is in the section, Trellis Description of a Convolutional Encoder.

The commands below illustrate how to use the final state and initial state arguments when invoking convenc repeatedly. Notice that [code3; code4] is the same as the earlier example's output, code1.

See Also

vitdec, poly2trellis, istrellis

References

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


 compand cyclgen