Main Content

ofdmmod

Modulate using OFDM method

Description

Y = ofdmmod(X,nfft,cplen) 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 by cplen. For information, see OFDM Modulation.

example

Y = ofdmmod(X,nfft,cplen,nullidx) 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 = ofdmmod(X,nfft,cplen,nullidx,pilotidx,pilots) 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 by pilotidx. For this syntax, the number of rows in the input X must equal nfftlength(nullidx)length(pilotidx). The function assumes pilot subcarrier locations are the same across each OFDM symbol and transmit stream.

example

Y = ofdmmod(X,nfft,cplen,___,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 for OversamplingFactor 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 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.

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 NDataSC-by-NSym-by-NStreams array, or a dlarray (Deep Learning Toolbox) object. For more information, see Array Support.

  • NDataSC is the number of data subcarriers. NDataSC = nfft – length(nullidx) – length(pilotidx).

  • NSym is the number of OFDM symbols per transmit stream.

  • NStreams is the number of transmit streams and must be less than or equal to the number of transmit antennas.

  • Symbols input data to an OFDM modulator are typically created with a baseband digital modulator, such as qammod.

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 (NDataSC) used in the modulation process. NDataSC = nfft – length(nullidx) – length(pilotidx)

Data Types: double

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

  • When you specify cplen as a scalar, the value must be in the range [0, nfft]. In this case, all symbols through all streams have the same cyclic prefix length.

  • When you specify cplen as a row vector of length NSym, the cyclic prefix length can vary across symbols but remains the same length through all streams.

NSym 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 NPilot-by-NSym-by-NStreams array of symbols, or a dlarray (Deep Learning Toolbox) object. For more information, see Array Support.

  • NPilot must equal the length of pilotidx.

  • NSym is the number of OFDM symbols per transmit stream.

  • NStreams is the number of transmit streams and must be less than or equal to the number of transmit antennas.

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 × NOut)-by-NStreams matrix of complex symbols or a dlarray (Deep Learning Toolbox) object. The output, Y, is a dlarray if either X or pilots is a dlarray. For more information, see Array Support.

  • osf is the oversampling factor, as determined by OversamplingFactor.

  • When cplen is a scalar, NCP = cplen and NOut = NSym × (nfft + NCP).

  • When cplen is a row vector, NCPTotal = sum(cplen) and NOut = (NSym × nfft) + NCPTotal.

  • NSym is the number of symbols per transmit stream.

  • NStreams is the number of transmit streams and is less than or equal to the number of transmit antennas.

Data Types: double | single
Complex Number Support: Yes

More About

collapse all

Algorithms

collapse all

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2018a

expand all

See Also

Functions

Objects

Blocks