# mil188qamdemod

MIL-STD-188-110 B/C standard-specific quadrature amplitude demodulation

## Description

performs QAM demodulation on an input signal, `z`

= mil188qamdemod(`y`

,`M`

)`y`

, that was
modulated in accordance with MIL-STD-188-110 and the modulation order,
`M`

. For a description of MIL-STD-188-110 QAM demodulation,
see MIL-STD-188-110 QAM Hard Demodulation and MIL-STD-188-110 QAM Soft Demodulation.

specifies options using one or more name-value pair arguments. For example,
`z`

= mil188qamdemod(`y`

,`M`

,`Name,Value`

)`'OutputDataType','double'`

specifies the desired output data
type as double. Specify name-value pair arguments after all other input
arguments.

## Examples

### Demodulate MIL-STD-188-110B Specific 16-QAM Signal

Demodulate a 16-QAM signal that was modulated as specified in MIL-STD-188-110B. Plot the received constellation and verify that the output matches the input.

Set the modulation order and generate random data.

M = 16; numSym = 20000; x = randi([0 M-1],numSym,1);

Modulate the data and pass through a noisy channel.

```
txSig = mil188qammod(x,M);
rxSig = awgn(txSig,25,'measured');
```

Plot the transmitted and received signal.

plot(rxSig,'b*') hold on; grid plot(txSig,'r*') xlim([-1.5 1.5]); ylim([-1.5 1.5]) xlabel('In-Phase') ylabel('Quadrature') legend('Received constellation','Reference constellation')

Demodulate the received signal. Compare the demodulated data to the original data.

z = mil188qamdemod(rxSig,M); isequal(x,z)

`ans = `*logical*
1

### Demodulate MIL-STD-188-110C Specific 64-QAM Signal

Demodulate a 64-QAM signal that was modulated as specified in MIL-STD-188-110C. Compute hard decision bit output and verify that the output matches the input.

Set the modulation order and generate random bit data.

M = 64; numBitsPerSym = log2(M); x = randi([0 1],1000*numBitsPerSym,1);

Modulate the data. Use name-value pairs to specify bit input data and to plot the constellation.

txSig = mil188qammod(x,M,'InputType','bit','PlotConstellation',true);

Demodulate the received signal. Compare the demodulated data to the original data.

z = mil188qamdemod(txSig,M,'OutputType','bit'); isequal(z,x)

`ans = `*logical*
1

### Soft Bit Demodulate MIL-STD-188-110 Specific 32-QAM Signal

Demodulate a 32-QAM signal and calculate soft bits.

Set the modulation order and generate a random bit sequence.

M = 32; numSym = 20000; numBitsPerSym = log2(M); x = randi([0 1], numSym*numBitsPerSym,1);

Modulate the data. Use name-value pairs to specify bit input data and unit average power, and to plot the constellation.

txSig = mil188qammod(x,M,'InputType','bit','UnitAveragePower',true, ... 'PlotConstellation',true);

Pass the transmitted data through white Gaussian noise.

`rxSig = awgn(txSig,10,'measured');`

View the constellation using a scatter plot.

scatterplot(rxSig)

Demodulate the signal, computing soft bits using the approximate LLR algorithm.

z = mil188qamdemod(rxSig,M,'OutputType','approxllr', ... 'NoiseVariance',10^(-1));

## Input Arguments

`y`

— Modulated signal

scalar | vector | matrix

Modulated signal, specified as a complex scalar, vector, or matrix. When
`y`

is a matrix, each column is treated as an
independent channel.

`y`

must be modulated in accordance with
MIL-STD-188-110 [1].

**Data Types: **`single`

| `double`

**Complex Number Support: **Yes

`M`

— Modulation order

integer

Modulation order, specified as a power of two. The modulation order specifies the total number of points in the signal constellation.

**Example: **`16`

**Data Types: **`double`

### Name-Value Arguments

Specify optional pairs of arguments as
`Name1=Value1,...,NameN=ValueN`

, where `Name`

is
the argument name and `Value`

is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.

*
Before R2021a, use commas to separate each name and value, and enclose*
`Name`

*in quotes.*

**Example: **```
y =
mil188qamdemod(x,M,'OutputType','bit','OutputDataType','single');
```

`OutputType`

— Output type

`'integer'`

(default) | `'bit'`

| `'llr'`

| `'approxllr'`

Output type, specified as the comma-separated pair consisting of
`OutputType`

and `'integer'`

,
`'bit'`

, `'llr'`

, or
`'approxllr'`

.

**Data Types: **`char`

| `string`

`OutputDataType`

— Output data type

`'double'`

(default) | `...`

Output data type, specified as the comma-separated pair consisting of
`OutputDataType`

and one of the indicated data
types. Acceptable values for `OutputDataType`

depend
on the `OutputType`

value.

`OutputType`
Value | Acceptable
`OutputDataType` Values |
---|---|

`'integer'` | `'double'` ,
`'single'` ,
`'int8'` ,
`'int16'` ,
`'int32'` ,
`'uint8'` ,
`'uint16'` , or
`'uint32'` |

`'bit'` | `'double'` ,
`'single'` ,
`'int8'` ,
`'int16'` ,
`'int32'` ,
`'uint8'` ,
`'uint16'` ,
`'uint32'` , or
`'logical'` |

#### Dependencies

This name-value pair argument applies only when
`OutputType`

is set to
`'integer'`

or `'bit'`

.

**Data Types: **`char`

| `string`

`UnitAveragePower`

— Unit average power flag

`false`

(default) | `true`

Unit average power flag, specified as the comma-separated pair
consisting of `UnitAveragePower`

and a logical
scalar. When this flag is `true`

, the function scales
the constellation to an average power of 1 watt referenced to 1 ohm.
When this flag is `false`

, the function scales the
constellation based on specifications in the relevant standard, as
described in [1].

**Data Types: **`logical`

`NoiseVariance`

— Noise variance

`1`

(default) | positive scalar | vector of positive values

Noise variance, specified as the comma-separated pair consisting of
`NoiseVariance`

and a positive scalar or vector
of positive values.

When specified as a scalar, the same noise variance value is used on all input elements.

When specified as a vector, the vector length must be equal to the number of columns in the input signal.

When the noise variance or signal power result in computations involving extreme positive or negative magnitudes, see MIL-STD-188-110 QAM Soft Demodulation for algorithm selection considerations.

#### Dependencies

This name-value pair argument applies only when
`OutputType`

is set to
`'llr'`

or
`'approxllr'`

.

**Data Types: **`double`

`PlotConstellation`

— Option to plot constellation

`false`

(default) | `true`

Option to plot constellation, specified as the comma-separated pair
consisting of `'PlotConstellation'`

and a logical
scalar. To plot the constellation, set
`PlotConstellation`

to
`true`

.

**Data Types: **`logical`

## Output Arguments

`z`

— Demodulated signal

scalar | vector | matrix

Demodulated signal, returned as a scalar, vector, or matrix. The
dimensions of `z`

depend on the specified
`OutputType`

value.

`OutputType`
Value | Return Value of
`mil188qamdemod` | Dimensions of `z` |
---|---|---|

`'integer'` | Demodulated integer values from 0 to
(`M` – 1) | `z` has the same dimensions as input
`y` . |

`'bit'` | Demodulated bits | The number of rows in `z`
is log_{2}(sum(`M` )) times the number of rows in
`y` . Each demodulated symbol is mapped
to a group of log_{2}(sum(`M` )) elements in a column, where the first
element represents the MSB and the last element represents
the LSB. |

`'llr'` | Log-likelihood ratio value for each bit | |

`'approxllr'` | Approximate log-likelihood ratio value for each bit |

## More About

### MIL-STD-188-110 QAM Hard Demodulation

The hard demodulation algorithm uses optimum decision region-based demodulation. Since all the constellation points are equally probable, maximum a posteriori probability (MAP) detection reduces to a maximum likelihood (ML) detection. The ML detection rule is equivalent to choosing the closest constellation point to the received symbol. The decision region for each constellation point is designed by drawing perpendicular bisectors between adjacent points. A received symbol is mapped to the proper constellation point based on which decision region it lies in.

Since all MIL-STD constellations are quadrant-based symmetric, for each symbol the optimum decision region-based demodulation:

Maps the received symbol into the first quadrant

Chooses the decision region for the symbol

Maps the constellation point back to its original quadrant using the sign of real and imaginary parts of the received symbol

### MIL-STD-188-110 QAM Soft Demodulation

For soft demodulation, two soft-decision log-likelihood ratio (LLR) algorithms are available: exact LLR and approximate LLR. The exact LLR algorithm is more accurate but has slower execution speed than the approximate LLR algorithm. For further description of these algorithms, see the Soft-Decision Demodulation topic.

**Note**

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.

## References

[1] MIL-STD-188-110B & C: "Interoperability and Performance Standards for Data Modems." Department of Defense Interface Standard, USA.

## Extended Capabilities

### C/C++ Code Generation

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

## Version History

**Introduced in R2018a**

## See Also

### Functions

### Objects

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

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