Main Content

comm.GeneralQAMDemodulator

Demodulate using arbitrary QAM constellation

Description

The comm.GeneralQAMDemodulator System object™ demodulates a signal modulated using the general quadrature amplitude modulation (QAM) technique.

To demodulate a general quadrature amplitude modulated signal:

  1. Create the comm.GeneralQAMDemodulator 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?

Creation

Description

gqamdemod = comm.GeneralQAMDemodulator creates a general QAM demodulator System object, gqamdemod. This object demodulates the input signal using the general quadrature amplitude modulation (QAM) method.

gqamdemod = comm.GeneralQAMDemodulator(const) sets the Constellation property to const.

gqamdemod = comm.GeneralQAMDemodulator(___,Name=Value) sets properties using one or more optional name-value arguments in addition to any of the input argument combinations in the previous syntaxes. For example, OutputDataType="double" sets the data type of the output to "double".

Properties

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.

Signal constellation, specified as a vector that lists the points in the signal constellation. The length of the constellation vector determines the modulation order.

Data Types: double
Complex Number Support: Yes

Output data format, specified as a logical 0 (false) or 1 (true).

  • When you set this property to true or 1, the demodulator outputs a column vector of bit values. The vector length is log2(M) multiplied by the number of demodulated symbols, where M is the modulation order as defined by the constellation size.

  • When you set this property to false or 0, the demodulator outputs a column vector of integer symbol values ranging from 0 to M–1. The vector length is equal to the length of the input data vector. M must be a power of two.

Data Types: logical

Decision method for the demodulation, specified as "Hard decision", "Log-likelihood ratio", or "Approximate log-likelihood ratio".

Dependencies

To enable this property, set the BitOutput property to true. When you set the BitOutput property to false, the object always performs hard decision demodulation.

Source of the noise variance, specified as "Property" or "Input port".

Dependencies

To enable this property, set the DecisionMethod property to "Log-likelihood ratio" or "Approximate log-likelihood ratio".

Noise variance, specified as a positive scalar.

Dependencies

To enable this property, set the VarianceSource property to "Property".

Tips

The exact LLR algorithm computes exponentials using finite precision arithmetic. For computations involving very large positive or negative magnitudes, the exact LLR algorithm yields:

  • Inf or -Inf if the noise variance is a very large value

  • NaN if the noise variance and signal power are both very small values

The approximate LLR algorithm does not compute exponentials. You can avoid Inf, -Inf, and NaN results by using the approximate LLR algorithm.

Data Types: double

Data type of the output, specified as "Full precision", "Smallest unsigned integer", "double", "single", "int8", "uint8", "int16", "uint16", "int32", or "uint32".

  • When you set the OutputDataType property to "Full precision", the output data type matches the input data type if the input data type is either single or double-precision.

  • When the data type of input signal is an integer data type, you must have a Fixed-Point Designer™ user license to use this property in the "Smallest unsigned integer" or "Full precision" mode.

  • When the input data type is of a fixed-point type, the output data type works as if you had set the OutputDataType property to "Smallest unsigned integer".

  • When you set the BitOutput property to true and the DecisionMethod property to "Hard Decision", the logical data type becomes a valid option.

  • When you set the BitOutput property to true and the DecisionMethod property to "Approximate log-likelihood ratio", you can set this property to "Full precision" only.

  • If you set the BitOutput property to true and the DecisionMethod property to "Log-likelihood ratio", the output data type matches the input data type for single or double precision values.

Dependencies

To enable this property, use one of these options:

  • Set the BitOutput property to false.

  • Set the BitOutput property to true and the DecisionMethod property to "Hard decision" or "Approximate log-likelihood ratio".

Fixed-Point Properties

Full-precision override for the fixed-point arithmetic, specified as a logical 0 (false) or 1 (true).

  • When you set the FullPrecisionOverride property to true or 1, the object computes all internal arithmetic and output data types using full-precision rules. These rules provide the most accurate fixed-point numerics. The object turns off the display of other fixed-point properties because they do not apply individually. These rules guarantee that no quantization occurs within the object. You can add bits, as needed, to ensure that no round-off or overflow occurs.

  • When you set the FullPrecisionOverride property to false or 0, the object controls fixed-point data types through individual fixed-point property settings.

For more information, see Full Precision for Fixed-Point System Objects.

Method for rounding of fixed-point numeric values, specified as "Ceiling", "Convergent", "Floor", "Nearest", "Round", "Simplest", or "Zero".

Dependencies

This property applies when the object is not in a full-precision configuration. This property does not apply when you set BitOutput to true and DecisionMethod to "Log-likelihood ratio".

Action when fixed-point numeric values overflow, specified as "Wrap" or "Saturate". This property specifies the action to be taken in the case of an overflow. Overflow occurs when the magnitude of a fixed-point calculation result does not fit into the range of the data type and scaling that stores the result.

Dependencies

This property applies when the object is not in a full-precision configuration. This property does not apply when you set BitOutput to true and DecisionMethod to "Log-likelihood ratio".

Data type of the signal constellation, specified as "Same word length as input" or "Custom".

Dependencies

This property does not apply when you set BitOutput to true and DecisionMethod to "Log-likelihood ratio".

Fixed-point data type of the custom signal constellation, specified as an unscaled numerictype (Fixed-Point Designer) object with a signedness of Auto.

Dependencies

To enable this property, set the ConstellationDataType property to "Custom".

Data type of the accumulator 1, specified as "Full precision" or "Custom".

Dependencies

To enable this property, set the FullPrecisionOverride property to false. However, it is not applicable when you set the BitOutput property to true and DecisionMethod to "Log-likelihood ratio".

Custom fixed-point data type of accumulator 1, specified as a scaled numerictype (Fixed-Point Designer) object with a signedness of Auto.

Dependencies

To enable this property, set the Accumulator1DataType property to "Custom".

Data type of the product input, specified as "Same as accumulator 1" or "Custom".

Dependencies

To enable this property, set the FullPrecisionOverride property to false. However, it is not applicable when you set the BitOutput property to true and DecisionMethod to "Log-likelihood ratio".

Custom fixed-point data type of the product input, specified as a scaled numerictype (Fixed-Point Designer) object with a signedness of Auto.

Dependencies

To enable this property, set the FullPrecisionOverride property to false and the ProductInputDataType property to "Custom".

Data type of the product output, specified as "Full precision" or "Custom".

Dependencies

To enable this property, set the FullPrecisionOverride property to false. However, this property does not apply when you set the BitOutput property to true and DecisionMethod to "Log-likelihood ratio".

Custom fixed-point data type of the product output, specified as a scaled numerictype (Fixed-Point Designer) object with a signedness of Auto

Dependencies

To enable this property, set the ProductOutputDataType property to "Custom".

Data type of accumulator 2, specified as "Full precision" or "Custom".

Dependencies

To enable this property, set the FullPrecisionOverride property to false. However, this property does not apply when you set the BitOutput property to true and DecisionMethod to "Log-likelihood ratio".

Custom fixed-point data type accumulator 2, specified as a scaled numerictype (Fixed-Point Designer) object with a Signedness of Auto.

Dependencies

To enable this property, set the Accumulator2DataType property to "Custom".

Data type of accumulator 3, "Full precision" or "Custom".

Dependencies

To enable this property, set the BitOutput property to true and DecisionMethod to "Approximate log-likelihood ratio".

Custom fixed-point data type of accumulator 3, specified as a scaled numerictype (Fixed-Point Designer) object with a signedness of Auto.

Dependencies

To enable this property, set the Accumulator3DataType property to "Custom".

Data type of the noise-scaling input, specified as "Same as accumulator 3" or 'Custom".

Dependencies

To enable this property, set the BitOutput property to true and the DecisionMethod property to "Approximate log-likelihood ratio".

Custom fixed-point data type of the noise-scaling input, specified as a scaled numerictype (Fixed-Point Designer) object with a signedness of Auto.

Dependencies

To enable this property, set the NoiseScalingInputDataType property to "Custom".

Data type of the inverse noise variance, specified as "Same word length as input" or "Custom".

Dependencies

To enable this property, set the BitOutput property to true, the DecisionMethod property to "Approximate log-likelihood ratio", and the VarianceSource property to "Property".

Custom fixed-point data type of the inverse noise variance, specified as a numerictype (Fixed-Point Designer) object with a Signedness of Auto.

Dependencies

To enable this property, set the InverseVarianceDataType property to "Custom".

Fixed-point data type of the output, specified as a scaled numerictype (Fixed-Point Designer) object with a signedness of Auto.

Dependencies

To enable this property, set the FullPrecisionOverride property to false and the OutputDataType property to "Custom".

Usage

Description

Y = gqamdemod(X) demodulates the input signal using the general QAM method.

example

Y = gqamdemod(X,vari) additionally specifies the noise variance, vari, and applies soft-decision demodulation to the input signal.

This syntax applies when you set the BitOutput property to true, the DecisionMethod property to "Approximate log-likelihood ratio" or "Log-likelihood ratio", and the VarianceSource property to "Input port".

Input Arguments

expand all

General quadrature amplitude modulated signal, specified as a scalar or column vector.

When you set the BitOutput property to true and the DecisionMethod property to "Log-likelihood ratio", the input data type must be single or double precision. Depending on the BitOutput property value, the output Y can be integer or bit valued.

Data Types: single | double | fi
Complex Number Support: Yes

Noise variance, specified as a positive scalar.

Data Types: single | double

Output Arguments

expand all

Output signal, returned as a scalar or column vector. To specify whether the object output values are integers or bits, use the BitOutput property. Specify the output data type using 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:

release(obj)

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

Examples

collapse all

Modulate and demodulate data using an arbitrary three-point constellation.

Define a three-point constellation for general quadrature amplitude modulation (QAM).

const = [1 1i -1];

Create general QAM modulator and demodulator System objects with the defined constellation.

gqamMod = comm.GeneralQAMModulator (const);
gqamdemod = comm.GeneralQAMDemodulator (const);

Create an error rate calculator.

errorRate = comm.ErrorRate
errorRate = 
  comm.ErrorRate with properties:

        ReceiveDelay: 0
    ComputationDelay: 0
             Samples: 'Entire frame'
      ResetInputPort: false

Run a loop to process frames of data by follwing these steps:

  1. Generate a random sequence of symbols.

  2. Modulate the random data to produce quadrature amplitude modulated symbols.

  3. Transmit the modulated symbols through the additive white Gaussian noise (AWGN) channel.

  4. Demodulate the received noisy symbols back to original data.

  5. Compute error statistics between transmitted and received data.

for counter = 1:100
     data = randi([0 2],50,1);
     modSignal = gqamMod(data);
     noisySignal = awgn(modSignal,5);
     receivedData = gqamdemod(noisySignal);
     errorStats = errorRate(data,receivedData);
end

Output the error rate and number of errors.

fprintf("Error rate = %f\nNumber of errors = %d\n", ...
      errorStats(1), errorStats(2))
Error rate = 0.045200
Number of errors = 226

More About

expand all

Algorithms

The general QAM demodulation algorithm comprises these steps:

  1. Define the signal constellation as a vector of length M, each mth element in the constellation vector mapped to an integer (m−1).

  2. Input a signal as a scalar or column vector.

  3. Use any of these decision methods to demodulate the signal:

    • Hard Decision — For each received sample, compute the Hamming distance to each constellation point. Select the symbol corresponding to the minimum Hamming distance. If multiple codewords tie for the minimum distance, randomly select one.

    • Log-likelihood Ratio (LLR) — For each received signal, calculate the LLR by taking the logarithm of the ratio of probabilities of transmitting a 0 bit versus a 1 bit. Use the LLR values to determine the most likely transmitted symbol for each bit.

    • Approximate Log-Likelihood Ratio (LLR) — For each bit position, identify the nearest constellation point that corresponds to a 0 and the nearest constellation point that corresponds to a 1. Based on the identified nearest constellation point, compute the LLR for each bit in the received signal.

For more information about the decision methods, see Hard- vs. Soft-Decision Demodulation.

Extended Capabilities

Version History

Introduced in R2012a