This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Convert convolutional code polynomials to trellis description


trellis = poly2trellis(ConstraintLength,CodeGenerator)
trellis = poly2trellis(ConstraintLength,CodeGenerator,...


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 or a k-by-n cell array of polynomial character vectors that specifies the n output connections for each of the encoder's k input bit streams.

trellis = poly2trellis(ConstraintLength,CodeGenerator,...
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 StructureDimensionsMeaning
numInputSymbolsScalar Number of input symbols to the encoder: 2k
numOutputSymbolsScalar Number of output symbols from the encoder: 2n
numStatesScalar Number of states in the encoder
nextStatesnumStates-by-2k matrix Next states for all combinations of current state and current input
outputsnumStates-by-2k 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.


collapse all

Create a trellis structure for a rate 2/3 feedforward convolutional code and display a portion of the next states of the trellis.

The structure of the encoder is depicted. As expected for rate 2/3 encoder, there are two input streams and three output streams.

Create a trellis, where the constraint length of the upper path is 5 and the constraint length of the lower path is 4. The octal representation of the code generator matrix corresponds to the taps from the upper and lower shift registers.

trellis = poly2trellis([5 4],[23 35 0; 0 5 13])
trellis = 

  struct with fields:

     numInputSymbols: 4
    numOutputSymbols: 8
           numStates: 128
          nextStates: [128×4 double]
             outputs: [128×4 double]

The structure field numInputSymbols equals 4 because two bit streams can produce four different input symbols while numOutputSymbols equals 8 because three bit streams produce eight different output symbols. As there are seven total shift registers, there are $2^7=128$ possible states as shown by trellis.nextStates.

Display the first five rows of the 128-by-4 trellis.nextStates matrix.

ans =

     0    64     8    72
     0    64     8    72
     1    65     9    73
     1    65     9    73
     2    66    10    74

An example of where this encoder is used is found in convenc.

Create a trellis structure for a rate 1/2 feedforward convolutional code and use it to encode and decode a random bit stream.

Create a trellis in which the constraint length is 7 and the code generator is specified as a cell array of polynomial character vectors.

trellis = poly2trellis(7,{'1 + x^3 + x^4 + x^5 + x^6', ...
    '1 + x + x^3 + x^4 + x^6'})
trellis = 

  struct with fields:

     numInputSymbols: 2
    numOutputSymbols: 4
           numStates: 64
          nextStates: [64×2 double]
             outputs: [64×2 double]

Generate random binary data, convolutionally encode the data, and decode the data using the Viterbi algorithm.

data = randi([0 1],70,1);
codedData = convenc(data,trellis);
decodedData = vitdec(codedData,trellis,34,'trunc','hard');

Verify that there are no bit errors in the decoded data.

ans =


Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a

Was this topic helpful?