Main Content


Demodulate and decode trellis-coded rectangular quadrature amplitude modulated signal


The comm.RectangularQAMTCMDemodulator System object™ object uses the Viterbi algorithm to decode a signal modulated by the trellis-coded modulation (TCM) technique with a rectangular quadrature amplitude modulation (QAM) signal constellation.

To demodulate and decode the trellis-coded rectangular QAM signal:

  1. Create the comm.RectangularQAMTCMDemodulator object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?



qamtcmDemod = comm.RectangularQAMTCMDemodulator creates a rectangular QAM TCM demodulator System object, qamtcmDemod. This object demodulates and decodes a trellis-coded rectangular QAM signal.

qamtcmDemod = comm.RectangularQAMTCMDemodulator(trellis) additionally sets the TrellisStructure property to trellis.


qamtcmDemod = comm.RectangularQAMTCMDemodulator(___,Name=Value) creates a rectangular QAM TCM demodulator System object using any of the previous syntaxes and sets properties using one or more name-value arguments. For example, comm.RectangularQAMTCMDemodulator(TerminationMethod="Continuous") sets the termination method of the encoded frame to "Continuous".


expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Trellis structure of the convolutional code, specified as a MATLAB® structure that contains the trellis description of the convolutional code. Use the istrellis function to check whether a trellis structure is valid.

The trellis structure contains these fields.

Number of symbols input to the encoder, specified as an integer equal to 2K, where K is the number of input bit streams.

Number of symbols output from the encoder, specified as an integer equal to 2N, where N is the number of output bit streams.

Number of states in the encoder, specified as a power of 2.

Next states for all combinations of current states and current inputs, specified as a matrix of integers. The matrix size must be numStates by 2K.

Outputs for all combinations of current states and current inputs, specified as a matrix of octal numbers. The matrix size must be numStates by 2K.

Data Types: struct

Termination method of the encoded frame, specified as one of these options.

  • "Continuous" — The object saves the internal state metric at the end of each frame. The next frame uses the same state metric. The object treats each traceback path independently. If the input signal contains only one symbol, use "Continuous" mode.

  • "Truncated" — The object treats each input vector independently. The traceback path starts at the state with the best metric and always ends in the all-zeros state.

  • "Terminated" — The object treats each input vector independently, and the traceback path always starts and ends in the all-zeros state.

Traceback depth for the Viterbi decoder, specified as a positive integer. The traceback depth influences the decoding accuracy and delay. The decoding delay is the number of zero symbols that precede the first decoded symbol in the output.

When you set the TerminationMethod property to "Continuous", the decoding delay consists of TracebackDepth zero symbols or (TracebackDepth×K) zero bits for a rate K/N convolutional code.

When you set the TerminationMethod property to "Truncated" or "Terminated", no output delay occurs and the traceback depth must be less than or equal to the number of symbols in each input vector.

Data Types: single | double

Demodulator reset input, specified as a logical 0 (false) or 1 (true). Set this property to true to call the object with an additional input. For nonzero reset input values, the object resets the state metrics and traceback memory of the demodulator to zero.


To enable this property, set theTerminationMethod property to "Continuous".

Number of points in the signal constellation, specified as 4, 8, 16, 32, or 64. The value of the ModulationOrder property must equal the number of possible output symbols from the convolutional decoder of the rectangular QAM TCM demodulator object. Therefore, the value for the ModulationOrder property must equal 2N for a rate K/N convolutional code.

Data Types: double

Data type of the output, specified as "logical" or "double".




Y = qamtcmDemod(X) demodulates the rectangular quadrature amplitude modulated data, X, and uses the Viterbi algorithm to decode the resulting demodulated bitstream encoded with a convolutional code.

Y = qamtcmDemod(X,R) resets the decoder to the all-zeros state when you input a reset signal, R, that is nonzero. This syntax applies when you set the value of the ResetInputPort property to true.

Input Arguments

expand all

Input data, specified as a column vector.

Data Types: double | logical
Complex Number Support: Yes

Reset signal, specified as a logical 0 (false), 1 (true), or numeric scalar.


To use this argument, set the ResetInputPort property to true.

Data Types: double | logical

Output Arguments

expand all

Output data, specified as a column vector. When the convolutional encoder represents a rate K/N code, the length of the output vector is (K×L), where L is the length of the input vector, X. The data type of the output data depends on the OutputDataType property.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:


expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object


collapse all

Modulate and demodulate data using rectangular 16-QAM TCM in an AWGN channel. Estimate the bit error rate (BER).

Create QAM TCM modulator and demodulator System objects.

rqamtcmod = comm.RectangularQAMTCMModulator;
rqamtcdemod = comm.RectangularQAMTCMDemodulator(TracebackDepth=16);

Determine the delay through the QAM TCM demodulator. The demodulator uses the Viterbi algorithm to decode the TCM signal that was modulated using rectangular QAM. The error rate calculation must align the received samples with the transmitted sample to accurately calculate the bit error rate. Calculate the delay in the system with the number of bits per symbol and the decoder traceback depth in the TCM demodulator.

bitsPerSymbol = log2(rqamtcdemod.TrellisStructure.numInputSymbols);
delay = rqamtcdemod.TracebackDepth*bitsPerSymbol;

Create an error rate calculator object with the ReceiveDelay property set to delay.

errRate = comm.ErrorRate(ReceiveDelay=delay);

Generate binary data and modulate it with 16-QAM TCM. Pass the signal through an AWGN channel and demodulate the signal. Calculate the error statistics. The loop runs until either 100 bit errors are encountered or 1e7 total bits are transmitted.

% Initialize the error results vector.
errStats = [0 0 0];

while errStats(2) < 100 && errStats(3) < 1e7
    % Transmit frames of 200 3-bit symbols
    txData = randi([0 1],600,1);
    % Modulate
    txSig = rqamtcmod(txData);
    % Pass through AWGN channel
    rxSig = awgn(txSig,5);
    % Demodulate
    rxData = rqamtcdemod(rxSig);
    % Collect error statistics
    errStats = errRate(txData,rxData);

Display the error data.

fprintf("Error rate = %4.2e\nNumber of errors = %d\n", ...
Error rate = 2.03e-03
Number of errors = 100

Extended Capabilities

Version History

Introduced in R2012a