This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Compute distance spectrum of convolutional code


spect = distspec(trellis,n)
spect = distspec(trellis)


spect = distspec(trellis,n) computes the free distance and the first n components of the weight and distance spectra of a linear convolutional code. Because convolutional codes do not have block boundaries, the weight spectrum and distance spectrum are semi-infinite and are most often approximated by the first few components. The input trellis is a valid MATLAB trellis structure, as described in Trellis Description of a Convolutional Code. The output, spect, is a structure with these fields:

spect.dfreeFree distance of the code. This is the minimum number of errors in the encoded sequence required to create an error event.
spect.weightA length-n vector that lists the total number of information bit errors in the error events enumerated in spect.event.
spect.eventA length-n vector that lists the number of error events for each distance between spect.dfree and spect.dfree+n-1. The vector represents the first n components of the distance spectrum.

spect = distspec(trellis) is the same as spect = distspec(trellis,1).


The example below performs these tasks:

  • Computes the distance spectrum for the rate 2/3 convolutional code that is depicted on the reference page for the poly2trellis function

  • Uses the output of distspec as an input to the bercoding function, to find a theoretical upper bound on the bit error rate for a system that uses this code with coherent BPSK modulation

  • Plots the upper bound using the berfit function

trellis = poly2trellis([5 4],[23 35 0; 0 5 13])
spect = distspec(trellis,4)
berub = bercoding(1:10,'conv','hard',2/3,spect); % BER bound
berfit(1:10,berub); ylabel('Upper Bound on BER'); % Plot.

The output and plot are below.

trellis = 

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

spect = 

     dfree: 5
    weight: [1 6 28 142]
     event: [1 2 8 25]


The function uses a tree search algorithm implemented with a stack, as described in [2].


[1] Bocharova, I. E., and B. D. Kudryashov, “Rational Rate Punctured Convolutional Codes for Soft-Decision Viterbi Decoding,” IEEE Transactions on Information Theory, Vol. 43, No. 4, July 1997, pp. 1305–1313.

[2] Cedervall, M., and R. Johannesson, “A Fast Algorithm for Computing Distance Spectrum of Convolutional Codes,” IEEE Transactions on Information Theory, Vol. 35, No. 6, Nov. 1989, pp. 1146–1159.

[3] Chang, J., D. Hwang, and M. Lin, “Some Extended Results on the Search for Good Convolutional Codes,” IEEE Transactions on Information Theory, Vol. 43, No. 5, Sep. 1997, pp. 1682–1697.

[4] Frenger, P., P. Orten, and T. Ottosson, “Comments and Additions to Recent Papers on New Convolutional Codes,” IEEE Transactions on Information Theory, Vol. 47, No. 3, March 2001, pp. 1199–1201.

Introduced before R2006a