OFDM with MIMO Simulation

This example shows how to the OFDM modulator and demodulator in a simple, 2×2 MIMO error rate simulation. The OFDM parameters are based on the 802.11n standard.

Construct a QPSK modulator and demodulator pair using the default settings.

hQMod = comm.QPSKModulator;
hQDemod = comm.QPSKDemodulator;

Construct an OFDM modulator and demodulator pair with user-specified pilot indices, an inserted DC null, two transmit antennas, and two receive antennas. Specify the pilot indices such that they vary from antenna to antenna.

hOFDMMod = comm.OFDMModulator('FFTLength',128,'PilotInputPort',true,...
    'PilotCarrierIndices',cat(3,[12; 40; 54; 76; 90; 118],...
    [13; 39; 55; 75; 91; 117]),'InsertDCNull',true,...
hOFDMDemod = comm.OFDMDemodulator(hOFDMMod);
hOFDMDemod.NumReceiveAntennas = 2;

Show the resource mapping of pilot subcarriers for each transmit antenna. The gray lines in the figure denote the insertion of null subcarriers to minimize pilot signal interference.


Construct an AWGN channel System object™ with a 30 dB Es/N0 ratio.

hAWGN = comm.AWGNChannel(...
    'NoiseMethod', 'Signal to noise ratio (Es/No)', ...
    'EsNo', 30);

Determine the dimensions of the OFDM modulator by using the info method and generate random data symbols to fill 100 OFDM frames.

modDim = info(hOFDMMod);

% Number of OFDM frames to transmit
nFrames = 100;

% Generate data for each (subcarrier, symbol, tx antenna) triplet
rng('default')         % Initialize random number generator to default seed
dataInputDim = [nFrames 1 1] .* modDim.DataInputSize;
data = randi([0 3], dataInputDim);

Apply QPSK modulation to the random symbols and size the resulting data to match the OFDM modulator requirements.

modData = step(hQMod, data(:));

modData = reshape(modData, dataInputDim);

Create an ErrorRate System object to collect error statistics.

hError = comm.ErrorRate;

Simulate the OFDM system over 100 frames assuming a flat, 2×2, Rayleigh fading channel. Remove the effects of multipath fading using a simple, least squares solution, and demodulate the OFDM waveform and QPSK data. Generate error statistics by comparing the original data with the demodulated data.

for k = 1:nFrames

    % Find row indices for kth OFDM frame
    indData = (k-1)*modDim.DataInputSize(1)+1:k*modDim.DataInputSize(1);

    % Generate random OFDM pilot symbols
    pilotData = complex(rand(modDim.PilotInputSize), ...

    % Modulate QPSK symbols using OFDM
    dataOFDM = step(hOFDMMod, modData(indData,:,:), pilotData);

    % Create flat, i.i.d., Rayleigh fading channel
    chGain = complex(randn(2,2),randn(2,2))/sqrt(2); % Random 2x2 channel

    % Pass the OFDM signal through Rayleigh and AWGN channels
    receivedSignal = step(hAWGN, dataOFDM * chGain);

    % Apply least squares solution to remove fading channel effects
    rxSigMF = chGain.' \ receivedSignal.';

    % Demodulate the OFDM data
    receivedOFDMData = step(hOFDMDemod, rxSigMF.');

    % Demodulate the QPSK data
    receivedData = step(hQDemod, receivedOFDMData(:));

    % Compute error statistics
    dataTmp = data(indData,:,:);
    errors = step(hError, dataTmp(:), receivedData);

Display the error data collected during the simulation.

fprintf('\nSymbol error rate = %d from %d errors in %d symbols\n',errors)
Symbol error rate = 9.471154e-02 from 1970 errors in 20800 symbols
Was this topic helpful?