# ofdmChannelResponse

## Syntax

## Description

returns the frequency response of a time-varying channel for OFDM signals with FFT length
equal to `hest`

= ofdmChannelResponse(`pathgains`

,`pathfilters`

,`nfft`

,`cplen`

)`nfft`

and cyclic prefix length equal to
`cplen`

. The channel is specified by `pathgains`

and
`pathfilters`

. For more information, see OFDM Channel Response.

## Examples

### OFDM Equalization for MIMO Channel with Beamforming

Obtain the channel response for a beamformed OFDM signal with ${\mathit{N}}_{\mathrm{S}}$ parallel data streams filtered through an ${\mathit{N}}_{\mathrm{T}}$-by-${\mathit{N}}_{\mathrm{R}}$ MIMO channel. Use the channel response to apply OFDM equalization to the received OFDM-demodulated signal.

Define simulation variables.

rng(1); numStreams = 2; % Number of parallel data streams (Ns) numTx = 4; % Number of transmit antennas (Nt) numRx = 3; % Number of receive antennas (Nr) bps = 6; % Bits per QAM symbol (and OFDM data subcarrier) nfft = 256; % FFT length cpLen = 16; % Cyclic prefix length numOFDMSym = 10; % Number of OFDM symbols SNRdB = 40; % Signal-to-noise ratio

Check that the number of data streams is no greater than either the number of transmit antennas or the number of receive antennas.

if numStreams > min(numTx,numRx) error('numStreams must be equal to or less than numTx and numRx.'); end

Configure OFDM subcarriers.

ofdmNullIdx = ... % Guard bands and DC subcarrier [1:9 (nfft/2+1) (nfft-8+1:nfft)]'; numDataSC = ... % Number of data subcarriers nfft-length(ofdmNullIdx);

Generate an array of data symbols consisting of ${\mathit{N}}_{\mathrm{S}}$ parallel data streams, QAM-modulate the symbols, and then OFDM-modulate the QAM-modulated symbols.

dataBits = randi([0,1],[numDataSC*bps numOFDMSym numStreams]); M = 2^bps; % Modulation order qamTx = qammod(dataBits,M, ... InputType="bit", ... UnitAveragePower=true); ofdmOut = ofdmmod(qamTx,nfft,cpLen,ofdmNullIdx);

Beamforming expands the dimensionality of the transmit signal to improve link performance over multipath channels. The data streams are fed through a beamformer that focuses the transmit energy over an ${\mathit{N}}_{\mathrm{T}}$-by-1 transmit antenna array where the number of antennas ${\mathit{N}}_{\mathrm{T}}\ge {\mathit{N}}_{\mathrm{S}}$.

Form a beamformer matrix from steering vectors acting on each stream.

% Beamform the transmitted signal fc = 1e9; lambda = physconst('LightSpeed')/fc; beamAngles = 15; antIdx = (0:numTx-1); antDelay = 2*pi*sin(2*pi*beamAngles*(0:numStreams-1).'/360)/lambda; B = exp(1i*antIdx.*antDelay); % Ns x Nt beamformer matrix txOut = ofdmOut * B;

Filter the OFDM-modulated signal through a MIMO channel to get the channel coefficients.

mimoChannel = comm.MIMOChannel( ... SampleRate=1e6, ... PathDelays=[0 3e-6 5e-6], ... AveragePathGains=[0 0.5 0.2], ... MaximumDopplerShift=0, ... SpatialCorrelationSpecification="None", ... NumTransmitAntennas=numTx, ... NumReceiveAntennas=numRx, ... PathGainsOutputPort=true); [channelOut,pathGains] = mimoChannel(txOut);

In a practical system, the channel must be sounded to estimate the channel response. Instead of sounding, the `ofdmChannelResponse`

function computes the exact channel response using the path gains and path filters that are available after you pass data through the MIMO channel System object. Use channel path gains returned by the MIMO channel object, and the path filters and timing offset returned by the `info`

object function, to obtain the OFDM channel response. If ${\mathit{N}}_{\mathrm{T}}<{\mathit{N}}_{\mathrm{R}}$, the channel forms an over-determined system (there are more receive antennas than necessary to adequately decode the transmitted signals). Call `ofdmChannelResponse`

with the `pathGains`

from the MIMO channel function to get the channel response.

mimoChannelInfo = info(mimoChannel); pathFilters = mimoChannelInfo.ChannelFilterCoefficients; toffset = mimoChannelInfo.ChannelFilterDelay; h = ofdmChannelResponse(pathGains,pathFilters,nfft,cpLen, ... setdiff(1:nfft,ofdmNullIdx),toffset); % Nsc x Nsym x Nt x Nr [rxIn,nVar] = awgn(channelOut,SNRdB,"measured");

Before demodulating the OFDM signal, account for the timing offset and symbol offset, remove the initial samples, and then pad with zeros to keep the signal length unchanged.

zeropadding = zeros(toffset,numRx); ofdmDemodIn = [rxIn(toffset+1:end,:); zeropadding]; symOffset = cpLen/2;

OFDM-demodulate and equalize the received signal.

rxSym = ofdmdemod(ofdmDemodIn,nfft,cpLen,symOffset,ofdmNullIdx);

The effects of beamforming and the MIMO channel affect the received data streams. The *effective channel* (${\mathit{H}}_{\mathrm{eff}}$) is an ${\mathit{N}}_{\mathrm{S}}$-by-${\mathit{N}}_{\mathrm{R}}$ matrix defined as the product of the transmit beamformer and the MIMO channel coefficients.

To use the OFDM channel response when equalizing the OFDM-demodulated signal, you must reshape the ${\mathit{N}}_{\mathit{SC}}$-by-${\mathit{N}}_{\mathrm{OFDMsym}}$-by-${\mathit{N}}_{\mathrm{T}}$-by-${\mathit{N}}_{\mathrm{R}}$ array to an ${\mathit{N}}_{\mathrm{QAMsym}}$-by-${\mathit{N}}_{\mathrm{T}}$-by-${\mathit{N}}_{\mathrm{R}}$ array. Form the effective channel using the beamformer matrix `B`

and the reshaped channel coefficients `h`

. Equalize the received OFDM signal using the calculated effective channel, the noise variance, and the MMSE algorithm.

hReshaped = reshape(h,[],numTx,numRx); hEff = zeros(numDataSC*numOFDMSym,numStreams,numRx); for k = 1:numOFDMSym*numDataSC hEff(k,:,:) = B * squeeze(hReshaped(k,:,:)); end eqSym = ofdmEqualize(rxSym,hEff,nVar);

Show the received OFDM-demodulated symbols (`rxSym`

) and the equalized OFDM-demodulated symbols (`eqSym`

). The constellation of the OFDM-demodulated symbols before equalization does not resemble the QAM constellation. After equalization, the constellation points lay near the reference constellation.

figure(1); scatterplot(rxSym(:));

figure(2); scatterplot(eqSym(:));

## Input Arguments

`pathgains`

— Channel path gains

numeric array | `dlarray`

object

Channel path gains, specified as an
*N*_{S}-by-*N*_{P}-by-*N*_{T}-by-*N*_{R}
numeric array, or a `dlarray`

(Deep Learning Toolbox)
object. For more information, see Array Support.

*N*_{S}is the number of samples.*N*_{P}is the number of paths.*N*_{T}is the number of transmit antennas.*N*_{R}is the number of receive antennas.

The channel path gains follow the definition of channel path gains as calculated and
output by the fading channel System objects. For example, see `comm.MIMOChannel`

, `comm.RayleighChannel`

, `comm.RicianChannel`

, or `comm.ChannelFilter`

. This function assumes that the path gains sample rate
matches the OFDM sample rate.

**Data Types: **`double`

| `single`

**Complex Number Support: **Yes

`pathfilters`

— Channel path filter coefficients

numeric matrix

Channel path filter coefficients, specified as an
*N*_{P}-by-*N*_{H}
numeric matrix.

*N*_{P}is the number of paths.*N*_{H}is the number of impulse response samples.

The coefficient matrix is used to convert path gains to channel filter tap gains for
each sample and each pair of transmit and receive antennas. The channel path filter
coefficients follow the definition of channel path filter coefficients as calculated by
the `info`

object function of the fading channel
System objects.

**Data Types: **`double`

| `single`

`nfft`

— FFT length

positive integer

FFT length, specified as a positive, integer scalar. The FFT length must align with that of the OFDM-modulated signal.

**Data Types: **`double`

| `single`

`cplen`

— Cyclic prefix length of one OFDM symbol

nonnegative integer

Cyclic prefix length of one OFDM symbol, specified as a nonnegative, integer scalar
with a value less than `nfft`

.

**Data Types: **`double`

| `single`

`activesc`

— Number of active subcarriers

`1:512`

(default) | positive integer | column vector

Number of active subcarriers, specified as a positive, integer scalar or column
vector of values in the range [`1`

, `nfft`

].

**Data Types: **`double`

| `single`

`toffset`

— Timing offset

`0`

(default) | nonnegative integer

Timing offset in samples, specified as a nonnegative, integer scalar. For more information, see OFDM Channel Response.

**Data Types: **`double`

| `single`

## Output Arguments

`hest`

— Frequency response

numeric array | `dlarray`

object

Frequency response, returned as an
*N*_{SC}-by-*N*_{Symbols}-by-*N*_{T}-by-*N*_{R}
numeric array, or a `dlarray`

(Deep Learning Toolbox)
object. If the input signal, `pathgains`

, is
a `dlarray`

, then this output, `hest`

, is also a
`dlarray`

.For more information, see Array Support.

*N*_{SC}is the number of OFDM subcarriers and is equal to the:*N*_{Symbols}is the number of whole OFDM symbols contained in`pathgains`

. Specifically, floor(*N*_{S}/(*N*_{FFT}+*L*_{CP})).*N*_{T}is the number of transmit antennas.*N*_{R}is the number of receive antennas.

## More About

### Array Support

The ofdmChannelResponse function supports input signals represented in a
numeric array, `dlarray`

(Deep Learning Toolbox), or
`gpuArray`

(Parallel Computing Toolbox).

The number of batch observations (*N*_{B}) is an
optional dimension that can be added to this input for all supported data types.

`pathgains`

— The channel path gains can be an array of up to five dimensions, specified as an*N*_{S}-by-*N*_{P}-by-*N*_{T}-by-*N*_{R}-by-*N*_{B}array.

*N*_{S} is the number of samples,
*N*_{P} is the number of paths,
*N*_{T} is the number of transmit antennas,and
*N*_{R} is the number of receive antennas.

For a list of Communications Toolbox™ features that support `dlarray`

objects, see AI for Wireless.

## Algorithms

### OFDM Channel Response

The OFDM channel response algorithm uses an FFT to compute the channel estimates by using the path gains and path filter coefficients available after you pass data through a MIMO channel. Use channel path gains returned by the MIMO channel object, and the path filters and timing offset returned by the `info`

object function, to estimate the OFDM channel response.

This figure shows one OFDM symbol in addition to the input channel impulse and the output channel impulse response. The algorithm ignores samples outside the OFDM symbol.

For a time-varying channel, such as most fading channels, the impulse response depends on the location of the impulse at the channel input.

## Extended Capabilities

### C/C++ Code Generation

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

Usage notes and limitations:

If dynamic memory allocation is off,

`nfft`

and`cplen`

must be compilation time constants. To enforce a static value, assign`nfft`

and`cplen`

by using`coder.const`

(MATLAB Coder).

### GPU Arrays

Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

This function supports GPU array inputs. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

## Version History

**Introduced in R2023a**

### R2024a: Add deep learning array support

The `ofdmChannelResponse`

function adds support for `dlarray`

(Deep Learning Toolbox) object
processing for deep learning applications.

### R2024a: Add GPU array support

The `ofdmChannelResponse`

function adds support for `gpuArray`

(Parallel Computing Toolbox) object processing to run code on a graphics processing unit
(GPU).

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