# 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:

Create the

`comm.GeneralQAMDemodulator`

object and set its properties.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

### Syntax

### Description

creates a general QAM demodulator System object, `gqamdemod`

= comm.GeneralQAMDemodulator`gqamdemod`

.
This object demodulates the input signal using the general quadrature amplitude
modulation (QAM) method.

sets the `gqamdemod`

= comm.GeneralQAMDemodulator(const)`Constellation`

property to
`const`

.

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,
`gqamdemod`

= comm.GeneralQAMDemodulator(___,`Name=Value`

)`OutputDataType="double"`

sets the data type of the
output to `"double"`

.

## Properties

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.

`Constellation`

— Signal constellation

exp(2×π×j×[0:7]/8) (default) | vector

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

`BitOutput`

— Output data format

`false`

or `0`

(default) | `true`

or `1`

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`

`DecisionMethod`

— Decision method for demodulation

`"Hard decision"`

(default) | `"Log-likelihood ratio"`

| `"Approximate log-likelihood ratio"`

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.

`VarianceSource`

— Source of noise variance

`"Property"`

(default) | `"Input port"`

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"
```

.

`Variance`

— Noise variance

`1`

(default) | positive scalar

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`

`OutputDataType`

— Data type of output

`"Full precision" `

(default) | `"Smallest unsigned integer"`

| `"double"`

| `"single"`

| `"int8"`

| `"uint8"`

| `"int16"`

| `"uint16"`

| `"int32"`

| `"uint32"`

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

`FullPrecisionOverride`

— Full-precision override for fixed-point arithmetic

`false`

or
`0`

(default) | `true`

or `1`

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.

`RoundingMethod`

— Method for rounding of fixed-point numeric values

`"Floor"`

(default) | `"Ceiling"`

| `"Convergent"`

| `"Nearest"`

| `"Round"`

| `"Simplest"`

| `"Zero"`

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"
```

.

`OverflowAction`

— Action when fixed-point numeric values overflow

`"Wrap"`

(default) | `"Saturate"`

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"
```

.

`ConstellationDataType`

— Data type of signal constellation

`"Same word length as input"`

(default) | `"Custom"`

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"
```

.

`CustomConstellationDataType`

— Unscaled fixed-point data type of custom signal constellation

`numerictype([],16)`

(default) | `numerictype`

object with signedness of
`Auto`

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"`

.

`Accumulator1DataType`

— Data type of accumulator 1

`"Full precision"`

(default) | `"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"
```

.

`CustomAccumulator1DataType`

— Custom fixed-point data type of accumulator 1

`numerictype([],32,30)`

(default) | `scaled numerictype`

object with a signedness of
`Auto`

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"`

.

`ProductInputDataType`

— Data type of product input

`"Same as accumulator 1"`

(default) | `"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"
```

.

`CustomProductInputDataType`

— Custom fixed-point data type of product input

`numerictype([],32,30)`

(default) | `numerictype`

object with a signedness of
`Auto`

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"`

.

`ProductOutputDataType`

— Data type of product output

`"Full precision"`

(default) | `"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"
```

.

`CustomProductOutputDataType`

— Custom fixed-point data type of product output

`numerictype([],32,30)`

(default) | `numerictype`

object with a signedness of
`Auto`

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"`

.

`Accumulator2DataType`

— Data type of accumulator 2

`"Full precision"`

(default) | `"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"
```

.

`CustomAccumulator2DataType`

— Custom fixed-point data type accumulator 2

`numerictype([],32,30)`

(default) | `numerictype`

object with a signedness of
`Auto`

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"`

.

`Accumulator3DataType`

— Data type of accumulator 3

`"Full precision"`

(default) | `"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"
```

.

`CustomAccumulator3DataType`

— Custom fixed-point data type of accumulator 3

`numerictype([],32,30)`

(default) | `numerictype`

object with a signedness of
`Auto`

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"`

.

`NoiseScalingInputDataType`

— Data type of noise-scaling input

`"Same as accumulator 3"`

(default) | `"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"
```

.

`CustomNoiseScalingInputDataType`

— Custom fixed-point data type of noise-scaling input

`numerictype([],32,30)`

(default) | `numerictype`

object with a signedness of
`Auto`

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"`

.

`InverseVarianceDataType`

— Data type of inverse noise variance

`"Same word length as input"`

(default) | `"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"`

.

`CustomInverseVarianceDataType`

— Custom fixed-point data type of inverse noise variance

`numerictype([],16,8)`

(default) | `numerictype`

object with a signedness of
`Auto`

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"`

.

`CustomOutputDataType`

— Fixed-point data type of output

`numerictype([],32,30)`

(default) | `numerictype`

object with a signedness of
`Auto`

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

additionally specifies the noise variance, `Y`

= gqamdemod(`X`

,vari)`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

`X`

— General quadrature amplitude modulated signal

scalar | column vector

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

`vari`

— Noise variance

positive scalar

Noise variance, specified as a positive scalar.

**Data Types: **`single`

| `double`

### Output Arguments

`Y`

— Output signal

scalar | column vector

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)

## Examples

### Demodulate Noisy General Quadrature Amplitude Modulated Signal

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:

Generate a random sequence of symbols.

Modulate the random data to produce quadrature amplitude modulated symbols.

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

Demodulate the received noisy symbols back to original data.

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

### Full Precision for Fixed-Point System Objects

`FullPrecisionOverride`

is a convenience property that,
when you set it to `true`

, automatically sets the appropriate properties
for an object to use full-precision to process fixed-point input.

For System objects, full precision, fixed-point operation refers to growing just enough
additional bits to compute the ideal full-precision result. This operation has no minimum or
maximum range overflow nor any precision loss due to rounding or underflow. It is also
independent of any hardware-specific settings. The data types chosen are based only on known
data type ranges and not on actual numeric values. Full-precision for System objects does
not optimize coefficient values. When you set the `FullPrecisionOverride`

property to `true`

, the other fixed-point properties it controls no longer
apply and any of their nondefault values are ignored. These properties are also hidden. To
specify individual fixed-point properties, first set
`FullPrecisionOverride`

to `false`

.

## Algorithms

The general QAM demodulation algorithm comprises these steps:

Define the signal constellation as a vector of length

*M*, each*m*th element in the constellation vector mapped to an integer (`m−1`

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

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

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

The

`Variance`

property is nontunable when using code generation.See System Objects in MATLAB Code Generation (MATLAB Coder).

## Version History

**Introduced in R2012a**

## See Also

### Functions

### Objects

### Blocks

## MATLAB 명령

다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.

명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)