Documentation |
trellis = poly2trellis(ConstraintLength,CodeGenerator)
trellis = poly2trellis(ConstraintLength,CodeGenerator,...
FeedbackConnection)
The poly2trellis function accepts a polynomial description of a convolutional encoder and returns the corresponding trellis structure description. The output of poly2trellis is suitable as an input to the convenc and vitdec functions, and as a mask parameter for the Convolutional Encoder, Viterbi Decoder, and APP Decoder blocks in Communications System Toolbox™ software.
trellis = poly2trellis(ConstraintLength,CodeGenerator) performs the conversion for a rate k/n feedforward encoder. ConstraintLength is a 1-by-k vector that specifies the delay for the encoder's k input bit streams. CodeGenerator is a k-by-n matrix of octal numbers that specifies the n output connections for each of the encoder's k input bit streams.
trellis = poly2trellis(ConstraintLength,CodeGenerator,...
FeedbackConnection) is the same as the syntax
above, except that it applies to a feedback, not feedforward, encoder. FeedbackConnection is
a 1-by-k vector of octal numbers that specifies the feedback connections
for the encoder's k input bit streams.
For both syntaxes, the output is a MATLAB^{®} structure whose fields are as in the table below.
Fields of the Output Structure trellis for a Rate k/n Code
Field in trellis Structure | Dimensions | Meaning |
---|---|---|
numInputSymbols | Scalar | Number of input symbols to the encoder: 2^{k} |
numOutputSymbols | Scalar | Number of output symbols from the encoder: 2^{n} |
numStates | Scalar | Number of states in the encoder |
nextStates | numStates-by-2^{k} matrix | Next states for all combinations of current state and current input |
outputs | numStates-by-2^{k} matrix | Outputs (in octal) for all combinations of current state and current input |
For more about this structure, see the reference page for the istrellis function.
An example of a rate 1/2 encoder is in Polynomial Description of a Convolutional Code.
As another example, consider the rate 2/3 feedforward convolutional encoder depicted in the figure below. The reference page for the convenc function includes an example that uses this encoder.
For this encoder, the ConstraintLength vector is [5,4] and the CodeGenerator matrix is [23,35,0; 0,5,13]. The output below reveals part of the corresponding trellis structure description of this encoder.
trellis = poly2trellis([5 4],[23 35 0; 0 5 13]) trellis = numInputSymbols: 4 numOutputSymbols: 8 numStates: 128 nextStates: [128x4 double] outputs: [128x4 double]
The scalar field trellis.numInputSymbols has the value 4 because the combination of two input bit streams can produce four different input symbols. Similarly, trellis.numOutputSymbols is 8 because the three output bit streams can produce eight different output symbols.
The scalar field trellis.numStates is 128 (that is, 2^{7}) because each of the encoder's seven memory registers can have one of two binary values.
To get details about the matrix fields trellis.nextStates and trellis.outputs, inquire specifically about them. As an example, the command below displays the first five rows of the 128-by-4 matrix trellis.nextStates.
trellis.nextStates(1:5,:) ans = 0 64 8 72 0 64 8 72 1 65 9 73 1 65 9 73 2 66 10 74
This first row indicates that if the encoder starts in the zeroth state and receives input bits of 00, 01, 10, or 11, respectively, the next state will be the 0th, 64th, 8th, or 72nd state, respectively. The 64th state means that the bottom-left memory register in the diagram contains the value 1, while the other six memory registers contain zeros.