mimo ofdm system outputioing snr vs ber grapj performing qpsk mod manually and selective fading in matlab

To generate the simulated BER vs SNR plot for a MIMO OFDM system using QPSK modulation in a selective fading channel:

  1. Define the system parameters such as the number of transmit and receive antennas, cyclic prefix length, FFT size, and channel parameters for selective fading.
main.m
% number of transmit antennas
numTx = 2;

% number of receive antennas
numRx = 2;

% cyclic prefix length
cpLen = 16;

% FFT size
fftSize = 64;

% channel parameters
maxDopplerShift = 30;
numPaths = 1;
channel = [
    0.8+0.6i -0.6+0.8i 0 0;
    0 0 0.9+0.4i -0.4+0.9i;
    0 0 0 0;
    0 0 0 0
];
298 chars
22 lines
  1. Generate random QPSK symbols for each transmit antenna and reshape them into a matrix where each column represents a transmit antenna.
main.m
numBitsPerSym = 2;
data = randi([0 1], numTx*fftSize*numBitsPerSym, 1);
qpskModulator = comm.QPSKModulator();
txSym = qpskModulator(data);
txSymMat = reshape(txSym, numTx, []);
177 chars
6 lines
  1. Perform an IFFT on the transmit symbols and add a cyclic prefix to each OFDM symbol.
main.m
txOFDM = ifft(txSymMat, fftSize, 2);
txCP = [txOFDM(:, end-cpLen+1:end) txOFDM];
81 chars
3 lines
  1. Pass the OFDM symbols through the channel and add AWGN noise.
main.m
rxCP = zeros(size(txCP));
for i = 1:numRx
    for j = 1:numTx
        rxCP(i, :) = rxCP(i, :) + sqrt(numTx)*sqrt(numRx)*conv(txCP(j, :), squeeze(channel(i,j,:)));
    end
    rxCP(i, :) = awgn(rxCP(i, :), snr, 'measured');
end
227 chars
8 lines
  1. Remove the cyclic prefix from each OFDM symbol, perform an FFT and demodulate the received QPSK symbols.
main.m
rxOFDM = rxCP(:,cpLen+1:end);
rxSymMat = fft(rxOFDM, fftSize, 2);
rxSym = rxSymMat(:);
qpskDemodulator = comm.QPSKDemodulator();
dataRx = qpskDemodulator(rxSym);
162 chars
6 lines
  1. Calculate the bit error rate (BER) for the received data and repeat the simulation for different SNR values.
main.m
numErrs = sum(dataRx ~= data);
ber = numErrs/(numTx*fftSize*numBitsPerSym);
76 chars
3 lines
  1. Plot the BER vs SNR curve using semilogy.
main.m
semilogy(snr, ber)
xlabel('SNR (dB)')
ylabel('BER')
title('MIMO OFDM QPSK in Selective Fading')
96 chars
5 lines

gistlibby LogSnag