MATLAB Examples

# OFDM with User-Specified Pilot Indices

This example shows how to construct an orthogonal frequency division modulation (OFDM) modulator/demodulator pair and to specify their pilot indices. The OFDM modulator System object enables you to specify pilot subcarrier indices consistent with the constraints described in comm.OFDMModulator.info. In this example, for OFDM transmission over a 3x2 channel, pilot indices are created for each of the three transmit antennas. Additionally, the pilot indices differ between odd and even symbols.

Create an OFDM modulator object having five symbols, three transmit antennas, and length six windowing.

```ofdmMod = comm.OFDMModulator('FFTLength',256, ... 'NumGuardBandCarriers',[12; 11], ... 'NumSymbols', 5, ... 'NumTransmitAntennas', 3, ... 'PilotInputPort',true, ... 'Windowing', true, ... 'WindowLength', 6); ```

Specify pilot indices for even and odd symbols for the first transmit antenna.

```pilotIndOdd = [20; 58; 96; 145; 182; 210]; pilotIndEven = [35; 73; 111; 159; 197; 225]; pilotIndicesAnt1 = cat(2, pilotIndOdd, pilotIndEven, pilotIndOdd, ... pilotIndEven, pilotIndOdd); ```

Generate pilot indices for the second and third antennas based on the indices specified for the first antenna. Concatenate the indices for the three antennas and assign them to the PilotCarrierIndices property.

```pilotIndicesAnt2 = pilotIndicesAnt1 + 5; pilotIndicesAnt3 = pilotIndicesAnt1 - 5; ofdmMod.PilotCarrierIndices = cat(3, pilotIndicesAnt1, pilotIndicesAnt2, pilotIndicesAnt3); ```

Create on OFDM demodulator with two receive antennas based on the existing OFDM modulator System object. Determine the data and pilot dimensions using the info function.

```ofdmDemod = comm.OFDMDemodulator(ofdmMod); ofdmDemod.NumReceiveAntennas = 2; dims = info(ofdmMod) ```
```dims = struct with fields: DataInputSize: [215 5 3] PilotInputSize: [6 5 3] OutputSize: [1360 3] ```

Generate data and pilot symbols for the OFDM modulator given the array sizes specified in modDim.

```dataIn = complex(randn(dims.DataInputSize), randn(dims.DataInputSize)); pilotIn = complex(randn(dims.PilotInputSize), randn(dims.PilotInputSize)); ```

Apply OFDM modulation to the data and pilots.

```modOut = ofdmMod(dataIn,pilotIn); ```

Pass the modulated data through a 3x2 random channel.

```chanGain = complex(randn(3,2), randn(3,2)); chanOut = modOut * chanGain; ```

Demodulate the received data using the OFDM demodulator object.

```[dataOut,pilotOut] = ofdmDemod(chanOut); ```

Show the resource mapping for the three transmit antennas. The gray lines in the figure show the placement of custom nulls to avoid interference among antennas.

```showResourceMapping(ofdmMod) ```

For the first transmit and first receive antenna pair, demonstrate that the input pilot signal matches the input pilot signal.

```pilotCompare = abs(pilotIn(:,:,1)*chanGain(1,1)) - abs(pilotOut(:,:,1,1)); max(pilotCompare(:) < 1e-10) ```
```ans = logical 1 ```