ofdmmod - Modulate using OFDM method - MATLAB (original) (raw)

Modulate using OFDM method

Syntax

Description

[Y](#d126e73913) = ofdmmod([X](#mw%5F53526653-d050-45e4-baa0-00d189f98df0),[nfft](#mw%5F74f02c12-35c3-4c80-8424-99664a61434e),[cplen](#mw%5F22c39084-d5ff-40e6-89c1-47770d6b079f)) modulates the frequency-domain input data subcarriers in X using the orthogonal frequency division multiplexing (OFDM) method with an FFT size specified by nfft and cyclic prefix length specified bycplen. For information, see OFDM Modulation.

example

[Y](#d126e73913) = ofdmmod([X](#mw%5F53526653-d050-45e4-baa0-00d189f98df0),[nfft](#mw%5F74f02c12-35c3-4c80-8424-99664a61434e),[cplen](#mw%5F22c39084-d5ff-40e6-89c1-47770d6b079f),[nullidx](#mw%5F311d40d8-0330-4e2a-a0f5-498f3298bf63)) inserts null subcarriers into the frequency domain input data signal prior to performing OFDM modulation. The null subcarriers are inserted at index locations from 1 to nfft, as specified by nullidx. For this syntax, the number of rows in the input X is the number of used data subcarriers and must equal nfftlength(`nullidx`). Use null carriers to account for guard bands and DC subcarriers. For information, see Subcarrier Allocation, Guard Bands and Guard Intervals.

example

[Y](#d126e73913) = ofdmmod([X](#mw%5F53526653-d050-45e4-baa0-00d189f98df0),[nfft](#mw%5F74f02c12-35c3-4c80-8424-99664a61434e),[cplen](#mw%5F22c39084-d5ff-40e6-89c1-47770d6b079f),[nullidx](#mw%5F311d40d8-0330-4e2a-a0f5-498f3298bf63),[pilotidx](#mw%5F1dc87f6a-8a7d-4ed0-a02c-1f3e68af5128),[pilots](#mw%5F2d1b811e-f95b-4ee8-bb58-7a5af3780a17)) inserts null and pilot subcarriers into the frequency domain input data symbols prior to performing OFDM modulation. The null subcarriers are inserted at the index locations specified by nullidx. The pilot subcarriers,pilots, are inserted at the index locations specified bypilotidx. For this syntax, the number of rows in the inputX must equal nfftlength(`nullidx`)length(`pilotidx`). The function assumes pilot subcarrier locations are the same across each OFDM symbol and transmit stream.

example

[Y](#d126e73913) = ofdmmod([X](#mw%5F53526653-d050-45e4-baa0-00d189f98df0),[nfft](#mw%5F74f02c12-35c3-4c80-8424-99664a61434e),[cplen](#mw%5F22c39084-d5ff-40e6-89c1-47770d6b079f),___,OversamplingFactor=Value) specifies the optional oversampling factor name-value argument in addition to input arguments in previous syntaxes. The oversampling factor for an upsampled output signal must be specified as a positive scalar, and the products (OversamplingFactor×nfft) and (OversamplingFactor×cplen) must both result in integers. For example,ofdmmod(X,nfft,cplen,OversamplingFactor=2) upsamples the output signal by a factor of two. The default value forOversamplingFactor is 1.

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 integer16. However, rounding 4/3 to1.333 when setting the oversampling factor results in a noninteger product of 15.9960, which results in a code error.

example

Examples

collapse all

OFDM-modulate a fully packed input over two transmit streams.

Initialize input parameters and generate a random data input signal assigning data subcarriers to all FFT bins. Perform OFDM modulation.

M = 16; % Modulation order for 16QAM nfft = 128; % FFT length cplen = 16; % Cyclic prefix length nSym = 5; % Number of symbols per RE nStreams = 2; % Number of transmit streams dataIn = randi([0 M-1],nfft,nSym,nStreams); qamSig = qammod(dataIn,M,'UnitAveragePower',true); y1 = ofdmmod(qamSig,nfft,cplen);

Apply OFDM modulation assigning null subcarriers.

Initialize input parameters and generate random data.

M = 16; % Modulation order for 16QAM nfft = 64; % FFT length cplen = 16; % Cyclic prefix length nSym = 10; % Number of symbols per RE

nullIdx = [1:6 33 64-4:64]'; numDataCarrs = nfft-length(nullIdx); inSym = randi([0 M-1],numDataCarrs,nSym);

QAM modulate data. Perform OFDM modulation.

qamSig = qammod(inSym,M,'UnitAveragePower',true); outSig = ofdmmod(qamSig,nfft,cplen,nullIdx);

Perform OFDM modulation to input frequency domain data signal varying cyclic prefix length applied to each symbol.

Initialize input parameters and generate random data.

M = 16; % Modulation order for 16QAM nfft = 64; cplen = [4 8 10 7 2 2 4 11 16 3]; nSym = 10; nullIdx = [1:6 33 64-4:64]'; numDataCarrs = nfft-length(nullIdx); inSym = randi([0 M-1],numDataCarrs,nSym);

QAM modulate the data symbols and perform OFDM modulation to the QAM signal.

qamSig = qammod(inSym,M,UnitAveragePower=true); outSig = ofdmmod(qamSig,nfft,cplen,nullIdx);

Apply OFDM modulation to a QPSK signal that is spatially multiplexed over two transmit streams.

Initialize input parameters and generate random data for each stream.

M = 4; % Modulation order for QPSK nfft = 64; cplen = 16; nSym = 5; nStreams = 2; nullIdx = [1:6 33 64-4:64]'; pilotIdx = [12 26 40 54]'; numDataCarrs = nfft-length(nullIdx)-length(pilotIdx); pilots = repmat(pskmod((0:M-1).',M),1,nSym,nStreams);

stream1 = randi([0 M-1],numDataCarrs,nSym); stream2 = randi([0 M-1],numDataCarrs,nSym);

QPSK modulate data individually for each stream. Perform OFDM modulation.

qpskSig(:,:,1) = pskmod(stream1,M); qpskSig(:,:,2) = pskmod(stream2,M); y1 = ofdmmod(qpskSig,nfft,cplen,nullIdx,pilotIdx,pilots);

OFDM-modulate data input, specifying null and pilot packing.

Initialize input parameters, defining locations for null and pilot subcarriers. Generate random data, apply 16-QAM to data, QPSK to pilots, and perform OFDM modulation.

M = 16; % Modulation order nfft = 64; % FFT length cplen = 16; % Cyclic prefix length nSym = 10; % Number of symbols per RE

nullIdx = [1:6 33 64-4:64]'; pilotIdx = [12 26 40 54]';

numDataCarrs = nfft-length(nullIdx)-length(pilotIdx); dataSym = randi([0 M-1],numDataCarrs,nSym); qamSig = qammod(dataSym,M,UnitAveragePower=true); pilots = repmat(pskmod((0:3).',4),1,nSym);

y2 = ofdmmod(qamSig,nfft,cplen,nullIdx,pilotIdx,pilots);

Apply OFDM modulation to symbols. Insert nulls in the OFDM grid and oversample the output signal.

Initialize variables for the modulation order, oversampling factor, FFT size, cyclic prefix length, and null indices.

M = 64; % Modulation order osf = 3; % Oversampling factor nfft = 256; % FFT length cplen = 16; % Cyclic prefix length

nullidx = [1:6 nfft/2+1 nfft-5:nfft]'; numDataCarrs = nfft-length(nullidx);

Generate data symbols, apply QAM, and OFDM-modulate the data.

x = randi([0 M-1],numDataCarrs,1); qamSig = qammod(x,M,UnitAveragePower=true); y = ofdmmod(qamSig,nfft,cplen,nullidx,OversamplingFactor=osf);

Input Arguments

collapse all

Input baseband signal, specified as an_N_DataSC-by-_N_Sym-by-_N_Streams array, or a dlarray (Deep Learning Toolbox) object. For more information, see Array Support.

Data Types: double | single
Complex Number Support: Yes

FFT length, specified as an integer greater than or equal to 8.nfft is the upper bound for the number of subcarriers (_N_DataSC) used in the modulation process. _N_DataSC =nfft – length(nullidx) – length(pilotidx)

Data Types: double

Cyclic prefix length, specified as a scalar or row vector of length_N_Sym. Cyclic prefix length must be nonnegative.

_N_Sym is the number of symbols per stream.

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

Data Types: double

Indices of null subcarrier locations, specified as a column vector with element values in the range [1, nfft].

Data Types: double

Indices of pilot subcarrier locations, specified as a column vector with element values in the range [1, nfft].

Data Types: double

Pilot subcarriers, specified as an_N_Pilot-by-_N_Sym-by-_N_Streams array of symbols, or a dlarray (Deep Learning Toolbox) object. For more information, see Array Support.

Tip

The function assumes pilot subcarrier locations are the same across each OFDM symbol and transmit stream. Use the comm.OFDMModulator System object™ to vary pilot subcarrier locations across OFDM symbols or streams.

Data Types: double | single

Output Arguments

collapse all

OFDM-modulated baseband signal, returned as an (osf ×_N_Out)-by-_N_Streams matrix of complex symbols or a dlarray (Deep Learning Toolbox) object. The output, Y, is adlarray if either X or pilots is a dlarray. For more information, see Array Support.

Data Types: double | single
Complex Number Support: Yes

More About

collapse all

The ofdmmod function supports input signals represented in an array, dlarray (Deep Learning Toolbox), or gpuArray (Parallel Computing Toolbox). If inputs are specified as a combination of dlarray and gpuArray, the returned matrix is a dlarray object on the GPU.

The number of batch observations (_N_B) is an optional dimension that can be added to these inputs for all supported data types.

_N_Pilot is the number of pilots, specifically the length of pilotidx._N_Sym is the number of OFDM symbols per data stream. _N_Streams is the number of transmit streams and must be less than or equal to the number of transmit antennas.

For a list of Communications Toolbox™ features that support dlarray objects, see AI for Wireless.

Algorithms

collapse all

OFDM belongs to the class of multicarrier modulation schemes. Because the operation can transmit multiple carriers simultaneously, noise does not influence OFDM to the same degree as single-carrier modulation.

OFDM operation divides a high-rate data stream into low-rate data substreams by decomposing the transmission frequency band into a number of contiguous individually modulated subcarriers. This set of parallel and orthogonal subcarriers carry the data stream occupying almost the same bandwidth as a wideband channel. By using narrow orthogonal subcarriers, the OFDM signal gains robustness over a frequency-selective fading channel and eliminates adjacent subcarrier interference. Intersymbol interference (ISI) is reduced because the lower data rate substreams have symbol durations larger than the channel delay spread.

This image shows a frequency domain representation of orthogonal subcarriers in an OFDM waveform.

The transmitter applies inverse fast Fourier transform (IFFT) to N symbols at a time. Typically, the output of the IFFT is the sum of the N orthogonal sinusoids:

where {X_k} are data symbols, and_T is the OFDM symbol time. The data symbols_X_k are typically complex and can be from any digital modulation alphabet (for example, QPSK, 16-QAM, 64-QAM, etc.).

The subcarrier spacing is Δ_f_ = 1/T, ensuring that the subcarriers are orthogonal over each symbol period:

An OFDM modulator consists of a serial-to-parallel conversion followed by a bank of_N_ complex modulators, individually corresponding to each OFDM subcarrier.

OFDM modulator showing serial-to-parallel conversion followed by a bank of N complex modulators, individually corresponding to each OFDM subcarrier, which are then summed

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.

Individual data, DC, pilot, and guard-band subcarriers

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 symbol period

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.

Extended Capabilities

Version History

Introduced in R2018a

expand all

The ofdmmod function adds support for C code generation with input signals stored as dlarray (Deep Learning Toolbox) objects.

When the ofdmmod function specifies the cyclic prefix length as a vector, you can now assign OFDM symbol cyclic prefix lengths greater than the FFT length.

The ofdmmod function adds support for dlarray (Deep Learning Toolbox) object processing for deep learning applications.

The ofdmmod function adds support for gpuArray (Parallel Computing Toolbox) object processing to run code on a graphics processing unit (GPU).