在 MIMO 仿真中应用 OFDM
在简单的 2×2 单用户 MIMO 误码率仿真中使用 OFDM 调制器和解调器。OFDM 参数基于 802.11n 标准。
创建一个具有用户指定的导频索引、插入的 DC 空载、两个发射天线和两个接收天线的 OFDM 调制器和解调器对组。指定随天线变化的导频索引。
ofdmMod = comm.OFDMModulator(FFTLength=128, ... PilotInputPort=true, ... NumSymbols=3, ... PilotCarrierIndices= ... cat(3,[12; 40; 54; 76; 90; 118],[13; 39; 55; 75; 91; 117]), ... InsertDCNull=true, ... NumTransmitAntennas=2); ofdmDemod = comm.OFDMDemodulator(ofdmMod); ofdmDemod.NumReceiveAntennas = 2;
显示每个发射天线的导频子载波的资源映射。图中的灰线表示插入空子载波以最小化导频信号干扰。
showResourceMapping(ofdmMod)


使用 info 方法确定 OFDM 调制器的维度。
ofdmModDim = info(ofdmMod); numDataSc = ofdmModDim.DataInputSize(1); % Number of data subcarriers numSym = ofdmModDim.DataInputSize(2); % Number of OFDM symbols numTxAnt = ofdmModDim.DataInputSize(3); % Number of transmit antennas
设置参数以使用 QPSK 调制生成 100 个 OFDM 帧。
nframes = 100;
M = 4; % Modulation order to QPSK创建一个误码率计数器。
errorRate = comm.ErrorRate;
假设使用一个平坦 2×2 瑞利衰落信道,对 100 个帧进行 OFDM 系统仿真。使用简单的最小二乘解消除多径衰落的影响,并解调 OFDM 波形和 QPSK 数据。通过比较原始数据与解调数据生成错误统计量。
for k = 1:nframes % Generate a frame of user data dataIn = randi([0 M-1],numDataSc*numSym*numTxAnt,1); % Split the user data into two different streams and map to QPSK % symbols streamDataOut = reshape(dataIn,numTxAnt,[]).'; mapperOut = pskmod(streamDataOut,M,pi/4); % Generate random OFDM pilot symbols pilotData = complex(rand(ofdmModDim.PilotInputSize), ... rand(ofdmModDim.PilotInputSize)); % Reshape the modulated data streams to match the OFDM modulator % requirements and modulate the symbols using OFDM ofdmModData = reshape(mapperOut,numDataSc,numSym,numTxAnt); dataOFDM = ofdmMod(ofdmModData,pilotData); % Create flat, i.i.d., Rayleigh fading channel 2-by-2 channel chGain = complex(randn(2,2),randn(2,2))/sqrt(2); % Pass OFDM signal through Rayleigh and AWGN channels receivedSignal = awgn(dataOFDM*chGain,30); % Apply least squares solution to remove effects of fading channel rxSigMF = chGain.' \ receivedSignal.'; % Demodulate OFDM data receivedOFDMData = ofdmDemod(rxSigMF.'); % Form the received streams receivedOFDMStreams = reshape(receivedOFDMData,[],numTxAnt); % Demodulate QPSK data receivedStreams = pskdemod(receivedOFDMStreams,M,pi/4); % Demap the data from each rx stream back to the user data receivedData = reshape(receivedStreams.',[],1); % Compute error statistics errors = errorRate(dataIn,receivedData); end
显示错误统计量。
fprintf('\nSymbol error rate = %d from %d errors in %d symbols\n',errors)Symbol error rate = 8.996795e-02 from 5614 errors in 62400 symbols