# comm.OFDMDemodulator

Demodulate using OFDM method

## Description

The `comm.OFDMDemodulator`

System object™ demodulates a time domain signal by using the orthogonal frequency division
multiplexing (OFDM) method. For more information, see OFDM Demodulation. The output is a baseband
representation of the input to the `comm.OFDMModulator`

companion object.

To demodulate an OFDM signal:

Create the

`comm.OFDMDemodulator`

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 an
OFDM demodulator System object that demodulates an input signal by using the orthogonal frequency division
demodulation method.`ofdmDemod`

= comm.OFDMDemodulator

specifies Properties using one or more name-value arguments. For example,
`ofdmDemod`

= comm.OFDMDemodulator(`Name`

=`Value`

)`comm.OFDMDemodulator(FFTLength=128)`

configures the object for a total
of 128 subcarriers.

sets the OFDM demodulator object properties based on the specified OFDM modulator
object.`ofdmDemod`

= comm.OFDMDemodulator(odfmMod)

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

`FFTLength`

— Number of FFT points

`64`

(default) | positive integer

Number of fast Fourier transform (FFT) points, specified as a positive, integer scalar. The length of the FFT must be greater than or equal to 8 and is equivalent to the number of subcarriers.

`NumGuardBandCarriers`

— Number of subcarriers allocated to left and right guard bands

`[6; 5]`

(default) | 2-by-1 integer vector

Number of subcarriers allocated to the left and right guard bands, specified as a
2-by-1 integer vector. The number of left and right guard-band subcarriers,
[*N*_{leftG};
*N*_{rightG}], must fall within [0,⌊*N*_{FFT} / 2 ⌋ − 1], where *N*_{FFT} is the total
number of subcarriers in the OFDM signal specified by `FFTLength`

. For more information,
see Subcarrier Allocation, Guard Bands, and Guard Intervals.

`RemoveDCCarrier`

— Option to remove DC subcarrier

`false`

or `0`

(default) | `true`

or `1`

Option to remove the null DC subcarrier, specified as a numeric or logical
`0`

(`false`

) or `1`

(`true`

). The null DC subcarrier is at the center of the frequency
band and has the index value:

(

*N*_{FFT}/ 2) + 1 when*N*_{FFT}is even.(

*N*_{FFT}+ 1) / 2 when*N*_{FFT}is odd.

*N*_{FFT} is the total number of
subcarriers in the OFDM signal specified by `FFTLength`

.

`PilotOutputPort`

— Option to output pilot subcarriers

`false`

or `0`

(default) | `true`

or `1`

Option to output pilot subcarriers, specified as a numeric or logical
`0`

(`false`

) or `1`

(`true`

). When you set this property to:

`false`

— Pilot information may be present but remains embedded in the output data.`true`

— The object separates the pilot subcarriers, specified by`PilotCarrierIndices`

, from the output data and outputs the demodulated pilot signal to the`pilot`

output variable.

`PilotCarrierIndices`

— Indices of pilot subcarrier locations

`[12; 26; 40; 54]`

(default) | column vector | matrix | 3D array

Indices of the pilot subcarrier locations, specified as a column vector, matrix, or 3D array with integer-element values in the range

$$\left[{N}_{\text{leftG}}+1,\text{\hspace{0.17em}}{N}_{\text{FFT}}/2\right]\cup \left[{N}_{\text{FFT}}/2+2,\text{\hspace{0.17em}}{N}_{\text{FFT}}-{N}_{\text{rightG}}\right],$$

where *N*_{FFT} is the total
number of subcarriers specified by `FFTLength`

, and
*N*_{leftG} and
*N*_{rightG} are the left and right guard bands
specified by `NumGuardBandCarriers`

.

You can assign the *N*_{Pilot} pilot carrier
indices to the same or different *N*_{Sym}
subcarriers for each symbol, and across *N*_{T}
transmit antennas.

When the pilot indices are the same for every symbol and transmit antenna, the property has dimensions of N

_{Pilot}-by-1.When the pilot indices vary across symbols, the property has dimensions of

*N*_{Pilot}-by-*N*_{Sym}.If the received signal assigned one symbol across multiple transmit antennas, the property has dimensions of

*N*_{Pilot}-by-1-by-*N*_{T}.If the indices vary across the number of symbols and transmit antennas, the property has dimensions of

*N*_{Pilot}-by-*N*_{Sym}-by-*N*_{T}.

**Tip**

To minimize interference between transmissions across more than one transmit antenna, the pilot indices per symbol must be mutually distinct across the antennas.

#### Dependencies

This property applies when you set `PilotOutputPort`

to
`1`

.

`CyclicPrefixLength`

— Length of cyclic prefix

`16`

(default) | positive integer | row vector

Length of the cyclic prefix for each OFDM symbol, specified as a positive, integer
scalar or row vector containing `NumSymbols`

elements. The cyclic
prefix length must be in the range [0, *N*_{FFT}],
where *N*_{FFT} is the total number of subcarriers
in the OFDM signal specified by `FFTLength`

. When you specify the
cyclic prefix length as a:

Scalar — The cyclic prefix length is the same for all symbols through all antennas.

Row vector — The cyclic prefix length may vary across symbols but does not vary across antennas.

`OversamplingFactor`

— Oversampling factor

`1`

(default) | positive scalar

Oversampling factor, specified as a positive scalar. The oversampling factor must satisfy these constraints:

(

`OversamplingFactor`

×`FFTLength`

) must be an integer value.(

`OversamplingFactor`

×`CyclicPrefixLength`

) must be an integer value.

**Tip**

If you set the oversampling factor to a noninteger rational number, specify a fractional value
rather than a decimal value. For example, with an FFT length of `12`

and an
oversampling factor of `4/3`

, their product is the integer
`16`

. However, rounding `4/3`

to
`1.333`

when setting the oversampling factor results in a noninteger
product of `15.9960`

, which results in a code error.

**Data Types: **`double`

`NumSymbols`

— Number of OFDM symbols

`1`

(default) | positive integer

Number of OFDM symbols in the time-frequency grid, specified as a positive, integer scalar.

`NumReceiveAntennnas`

— Number of receive antennas

1 (default) | positive integer

Number of receive antennas to receive the OFDM modulated signal, specified as a
positive, integer scalar less than or equal to `64`

.

## Usage

### Description

`[`

separates the `Y`

,`pilot`

] = ofdmDemod(`X`

)`pilot`

signal on the subcarriers specified by the
`PilotCarrierIndices`

property value. To enable this syntax, set the `PilotOutputPort`

property to
true.

### Input Arguments

`X`

— OFDM-modulated baseband signal

matrix

OFDM-modulated baseband signal, specified as an (*osf* ×
*N*_{In})-by-*N*_{R} matrix.

*osf*is the oversampling factor, as determined by`OversamplingFactor`

.*N*_{In}=*N*_{CPTotal}+ (*N*_{FFT}×*N*_{Sym})*N*_{CPTotal}represents the cyclic prefix length over all the symbols.*N*_{CP}represents the cyclic prefix length as determined by`CyclicPrefixLength`

.When

`CyclicPrefixLength`

is a scalar,*N*_{CPTotal}=*N*_{CP}×*N*_{Sym}.When

`CyclicPrefixLength`

is a row vector,*N*_{CPTotal}= ∑*N*_{CP}.

*N*_{FFT}represents the number of subcarriers, determined by`FFTLength`

.*N*_{Sym}represents the number of symbols, determined by`NumSymbols`

.*N*_{R}represents the number of receive antennas, determined by`NumReceiveAntennnas`

.

You can determine the dimensions by using the `info`

object function.

**Data Types: **`double`

| `single`

**Complex Number Support: **Yes

### Output Arguments

`Y`

— Output baseband signal

matrix | 3D array

Output baseband signal, returned as a matrix or
*N*_{Out}-by-*N*_{Sym}-by-*N*_{R}
array of the same data type as the input signal. The output reduces to a matrix when
*N*_{R} is `1`

.

*N*_{Out}is the number of data subcarriers. For more information, see the`info`

object function.*N*_{Sym}is the number of symbols, as specified by`NumSymbols`

.*N*_{R}is the number of receive antennas, as specified by`NumReceiveAntennnas`

.

For more information, see Subcarrier Allocation, Guard Bands, and Guard Intervals.

**Data Types: **`double`

| `single`

**Complex Number Support: **Yes

`pilot`

— Pilot signal

3D array | 4D array

Pilot signal, returned with the same data type as the input signal and as an:

3D array with dimensions

*N*_{Pilot}-by-*N*_{Sym}-by-*N*_{R}when`PilotCarrierIndices`

is a vector or matrix.4D array with dimensions

*N*_{Pilot}-by-*N*_{Sym}-by-*N*_{T}-by-*N*_{R}array when`PilotCarrierIndices`

is a 3D array.

Where:

*N*_{Pilot}is the number of pilot subcarriers in each symbol, as specified by`size`

(`PilotCarrierIndices`

,`1`

).*N*_{Sym}is the number of symbols, as specified by`NumSymbols`

.*N*_{R}is the number of receive antennas, as specified by`NumReceiveAntennnas`

.*N*_{T}is the number of transmit antennas.

#### Dependencies

To return this output, set the `PilotOutputPort`

property to `true`

.

**Data Types: **`double`

| `single`

**Complex Number Support: **Yes

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

### Specific to `comm.OFDMDemodulator`

`info` | Provide dimensioning information for OFDM demodulator |

`showResourceMapping` | Show subcarrier mapping of OFDM symbols created by OFDM modulator or demodulator System object |

## Examples

### Create and Modify OFDM Demodulator

Create an OFDM demodulator System object™ with default properties. Modify some of the properties. Inspect the object configuration by using the `info`

object function.

ofdmDemod = comm.OFDMDemodulator

ofdmDemod = comm.OFDMDemodulator with properties: FFTLength: 64 NumGuardBandCarriers: [2x1 double] RemoveDCCarrier: false PilotOutputPort: false CyclicPrefixLength: 16 OversamplingFactor: 1 NumSymbols: 1 NumReceiveAntennas: 1

info(ofdmDemod)

`ans = `*struct with fields:*
InputSize: [80 1]
DataOutputSize: [53 1]

Modify the number of subcarriers, symbols, and receive antennas. Also enable the pilot output.

ofdmDemod.FFTLength = 128; ofdmDemod.PilotOutputPort = 1; ofdmDemod.NumSymbols = 2; ofdmDemod.NumReceiveAntennas = 2;

Verify that the number of subcarriers and the number of symbols changed. Reinspect the input and output signal dimensions by using the `info`

object function. Notice the addition of the pilot output dimensions to the information structure. because the number of receive antennas is greater than 1, the data and pilot output dimensions are 3D arrays rather than matrices.

ofdmDemod

ofdmDemod = comm.OFDMDemodulator with properties: FFTLength: 128 NumGuardBandCarriers: [2x1 double] RemoveDCCarrier: false PilotOutputPort: true PilotCarrierIndices: [4x1 double] CyclicPrefixLength: 16 OversamplingFactor: 1 NumSymbols: 2 NumReceiveAntennas: 2

info(ofdmDemod)

`ans = `*struct with fields:*
InputSize: [288 2]
DataOutputSize: [113 2 2]
PilotOutputSize: [4 2 2]

### Create OFDM Demodulator from OFDM Modulator

Creating the demodulator by using the configured modulator ensures a matched modulator and demodulator pair.

Create an OFDM modulator specifying four transmit antennas.

ofdmMod = comm.OFDMModulator(NumTransmitAntennas=4);

Use the OFDM modulator to create the OFDM demodulator.

ofdmDemod = comm.OFDMDemodulator(ofdmMod);

Display the properties of the OFDM modulator and demodulator, verifying that the applicable properties match. The number of transmit antennas is independent of the number of receive antennas.

ofdmMod

ofdmMod = comm.OFDMModulator with properties: FFTLength: 64 NumGuardBandCarriers: [2x1 double] InsertDCNull: false PilotInputPort: false CyclicPrefixLength: 16 Windowing: false OversamplingFactor: 1 NumSymbols: 1 NumTransmitAntennas: 4

ofdmDemod

ofdmDemod = comm.OFDMDemodulator with properties: FFTLength: 64 NumGuardBandCarriers: [2x1 double] RemoveDCCarrier: false PilotOutputPort: false CyclicPrefixLength: 16 OversamplingFactor: 1 NumSymbols: 1 NumReceiveAntennas: 1

### Visualize Time-Frequency Resource Assignments

The `showResourceMapping`

object function shows the time-frequency resource mapping for each transmit antenna.

Create an OFDM demodulator.

demod = comm.OFDMDemodulator;

Display the OFDM subcarrier mapping by using the `showResourceMapping`

object function.

showResourceMapping(demod)

Remove the DC subcarrier.

demod.RemoveDCCarrier = true;

Show the resource mapping after removing the DC subcarrier.

showResourceMapping(demod)

### Demodulate OFDM Data

Create an OFDM modulator with an inserted DC null, seven guard-band subcarriers, and two symbols that have different pilot indices for each symbol.

ofdmMod = comm.OFDMModulator( ... NumGuardBandCarriers=[4; 3], ... PilotInputPort=true, ... PilotCarrierIndices=cat(2,[12; 26; 40; 54],[11; 27; 39; 55]), ... NumSymbols=2, ... InsertDCNull=true);

Determine input data, pilot, and output data dimensions.

modDim = info(ofdmMod)

`modDim = `*struct with fields:*
DataInputSize: [52 2]
PilotInputSize: [4 2]
OutputSize: [160 1]

Generate random data symbols for the OFDM modulator. Determine the number of data symbols by using the structure variable, `modDim`

.

```
dataIn = complex( ...
randn(modDim.DataInputSize),randn(modDim.DataInputSize));
```

Create a pilot signal that has the correct dimensions.

```
pilotIn = complex( ...
rand(modDim.PilotInputSize),rand(modDim.PilotInputSize));
```

Apply OFDM modulation to the data and pilot signals.

modSig = ofdmMod(dataIn,pilotIn);

Use the OFDM modulator object to create the corresponding OFDM demodulator.

ofdmDemod = comm.OFDMDemodulator(ofdmMod);

Demodulate the OFDM signal and output the data and pilot signals.

[dataOut,pilotOut] = ofdmDemod(modSig);

Verify that the input data and pilot symbols match the output data and pilot symbols.

```
isSame = (max(abs([dataIn(:) - dataOut(:); ...
pilotIn(:) - pilotOut(:)])) < 1e-10)
```

`isSame = `*logical*
1

### Oversample and Filter OFDM Signal Through SISO Channel

Filter an OFDM modulated signal with data and pilot inputs and outputs generated at four times the sample rate through a single-input single-output (SISO) channel. Demodulate the channel-filtered signal and compare to the original data.

Create an OFDM demodulator object that has three symbols and different pilot subcarrier indices and cyclic prefix lengths for each symbol.

ofdmDemod = comm.OFDMDemodulator( ... NumGuardBandCarriers=[9;8], ... RemoveDCCarrier=true, ... PilotOutputPort=true, ... PilotCarrierIndices=[[12;26;40;54],[14;28;38;52],[12;26;40;54]], ... CyclicPrefixLength=[16 32 16], ... OversamplingFactor=4, ... NumSymbols=3);

Create an OFDM modulator System object from the OFDM demodulator object, `ofdmDemod`

.

ofdmMod = comm.OFDMModulator(ofdmDemod);

Show the configured subcarrier resource mapping for data, pilot, guard band and null signals by using the `showResourceMapping`

object function. Obtain the input and output dimension information by using the `info`

object function.

showResourceMapping(ofdmDemod);

modDim = info(ofdmMod);

Create random data and pilot inputs and apply QAM modulation.

M = 16; xd = randi([0 M-1],modDim.DataInputSize); dataIn = qammod(xd,M,UnitAveragePower=true); xp = randi([0 M-1],modDim.PilotInputSize); pilotIn = qammod(xp,M,UnitAveragePower=true);

Apply OFDM modulation to the data and pilot QAM signals. Filter the signal through an AWGN channel. To recover the data and pilot symbols, apply OFDM demodulation and then QAM-demodulation.

```
modOut = ofdmMod(dataIn,pilotIn);
chanOut = awgn(modOut,20,"measured");
[dataOut, pilotOut] = ofdmDemod(chanOut);
yd = qamdemod(dataOut,M,UnitAveragePower=true);
yp = qamdemod(pilotOut,M,UnitAveragePower=true);
```

Verify that the data and pilots are unchanged through this process.

dataSame = isequal(xd,yd)

`dataSame = `*logical*
1

pilotSame = isequal(xp,yp)

`pilotSame = `*logical*
1

## Algorithms

### OFDM Demodulation

The orthogonal frequency division multiplexing (OFDM) method demodulates an OFDM input signal by using an FFT operation that results in *N* parallel data streams.

The figure shows an OFDM demodulator consisting of a bank of *N* correlators with one correlator assigned to each OFDM subcarrier. A parallel-to-serial conversion follows the correlator bank.

### Subcarrier Allocation, Guard Bands, and Guard Intervals

Individual OFDM subcarriers are allocated as data, pilot, or null subcarriers.

As shown here, subcarriers are designated as data, DC, pilot, or guard-band subcarriers.

Data subcarriers transmit user data.

Pilot subcarriers are for channel estimation.

Null subcarriers transmit no data. Subcarriers with no data provide a DC null and serve as buffers between OFDM resource blocks.

The null DC subcarrier is the center of the frequency band with an index value of (

`nfft`

/2 + 1) if`nfft`

is even, or ((`nfft`

+ 1) / 2) if`nfft`

is odd.The guard bands provide buffers between adjacent signals in neighboring bands to reduce interference caused by spectral leakage.

Null subcarriers enable you to model guard bands and DC subcarrier locations for specific standards, such as the various 802.11 formats, LTE, WiMAX, or for custom allocations. You can allocate the location of nulls by assigning a vector of null subcarrier indices.

Similar to guard bands, guard intervals protect the integrity of transmitted signals in OFDM by reducing intersymbol interference.

Assignment of guard intervals is analogous to the assignment of guard bands. You can model guard intervals to provide temporal separation between OFDM symbols. The guard intervals help preserve intersymbol orthogonality after the signal passes through time-dispersive channels. You create guard intervals by using cyclic prefixes. Cyclic prefix insertion copies the last part of an OFDM symbol as the first part of the OFDM symbol.

OFDM benefits from the use of cyclic prefix insertion as long as the span of the time dispersion does not exceed the duration of the cyclic prefix.

Inserting a cyclic prefix results in a fractional reduction of user data throughput because the cyclic prefix occupies bandwidth that could be used for data transmission.

## References

[1] Dahlman, E., S. Parkvall, and J. Skold. *4G
LTE/LTE-Advanced for Mobile Broadband*. London: Elsevier Ltd., 2011.

[2] Andrews, J. G., A. Ghosh, and R. Muhamed.
*Fundamentals of WiMAX*. Upper Saddle River, NJ: Prentice Hall,
2007.

[3] IEEE^{®} Standard 802.16-2017. "Part 16: Air Interface for Broadband Wireless Access
Systems." March 2018.

## Extended Capabilities

### C/C++ Code Generation

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

Usage notes and limitations:

See System Objects in MATLAB Code Generation (MATLAB Coder).

## Version History

**Introduced in R2014a**

### R2023b: Single data type support

If the input signal is of type single, then the object natively computes in single precision, and the returned output is also of type single.

### R2023a: Adds support for oversampling

`comm.OFDMDemodulator`

now supports oversampling.

## See Also

### Functions

### Objects

### Blocks

### Functions

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