Assignment Chef icon Assignment Chef
All English tutorials

Programming lesson

Simulating OFDM Communications in Frequency-Selective Fading Channels with MATLAB

Learn step-by-step how to model L-ray Rayleigh fading channels and simulate OFDM systems in MATLAB, including channel estimation and error correction coding.

OFDM simulation MATLAB Rayleigh fading channel model QPSK modulation MATLAB symbol error rate SER frequency selective fading channel estimation pilots repetition coding diversity circulant channel matrix OFDM system simulation wireless communications MATLAB 5G OFDM tutorial Wi-Fi 6 simulation multipath channel modeling error correction coding OFDM adaptive subcarrier disabling

Introduction to OFDM Simulation in MATLAB

Orthogonal Frequency Division Multiplexing (OFDM) is the backbone of modern wireless systems like 5G, Wi-Fi 6, and even satellite communications. In this tutorial, you'll learn how to simulate an OFDM communication system over frequency-selective fading channels using MATLAB. We'll cover channel modeling, QPSK modulation, input-output relationships, and performance evaluation via Symbol Error Rate (SER) plots. This guide aligns with the ELEC0086 Communications Systems Modelling lab, helping you build intuition through hands-on simulation.

1. Simulating L-Ray Equal-Power Rayleigh Fading Channels

1.1 Generating the Number of Rays with Poisson Distribution

The first step is to model a multipath channel where the number of paths (rays) is random. Use a Poisson random variable L to decide the number of rays. In MATLAB, you can generate it using poissrnd(lambda). For example, with an average of 4 rays, L = poissrnd(4). This randomness reflects real-world environments where the number of significant echoes varies.

1.2 Generating Rayleigh Fading Coefficients

For each ray, generate a complex fading coefficient with Rayleigh-distributed amplitude and uniform phase. The amplitude follows a Rayleigh distribution with scale parameter sigma = sqrt(1/(2*L)) to ensure unit average power. Use abs(randn + 1j*randn)*sigma for each coefficient. The phase is implicitly uniform due to the complex Gaussian generation.

1.3 Modeling Time Delays

Time delays for each ray are modeled as uniform random variables between 0 and 2 (e.g., in microseconds). Generate tau = 2 * rand(L,1). These delays determine the channel's frequency selectivity.

1.4 Plotting the Channel Impulse Response

Use stem(tau, abs(alpha)) to plot the impulse response. Normalize the average power: E[|alpha_i|^2] = 1/L. This ensures the total power is unity regardless of L. For verification, compute mean(abs(alpha).^2) * L over many realizations.

1.5 Generating Multiple Independent Realizations

Repeat the above steps (e.g., 1000 times) to obtain a set of channel impulse responses. This allows averaging SER over channel randomness.

2. Simulation of QPSK Symbols

Generate N independent QPSK symbols. In MATLAB, map bits to symbols: s = (2*randi([0,1],N,1)-1 + 1j*(2*randi([0,1],N,1)-1))/sqrt(2). This yields symbols with average power 1.

3. Input-Output Relationship Without OFDM

3.1 Obtaining the Pulse-Shaped Channel Matrix

Assuming a rectangular pulse shape, the matrix G (size N x N) is constructed from the channel impulse response. Each column represents the delayed and scaled pulse. Use a loop to populate G(m,n) = alpha_k where m = n + tau_k (with appropriate indices).

3.2 Generating Noise Samples

Generate zero-mean complex Gaussian noise with variance sigma2: n = sqrt(sigma2/2)*(randn(N,1) + 1j*randn(N,1)).

3.3 Generating the Received Signal

The received signal is y = G*s + n. This models the convolution of transmitted symbols with the channel.

3.4 SER Calculation and Detection

For detection, remove the channel perturbation by multiplying with the inverse of G (or using zero-forcing). Then compare detected symbols with original to compute SER. Average over many channel realizations and noise seeds.

3.5 Plotting SER vs SNR

Plot SER against 10*log10(1/sigma2) (SNR in dB). Vary parameters like number of rays L, delay spread, or pulse shape to observe effects.

4. Simulation of the OFDM System

4.1 Circulant Channel Matrix

With cyclic prefix, the channel matrix becomes circulant. Construct it from the impulse response: H = toeplitz([alpha(1); zeros(N-1,1)], [alpha(1) fliplr(alpha(2:end))]). This simplifies equalization.

4.2 IFFT of Symbols

Compute X = ifft(s) to get time-domain OFDM symbol.

4.3 Received Signal

After adding cyclic prefix and passing through channel, y = H*X + n. Remove cyclic prefix at receiver.

4.4 FFT of Received Signal

Compute Y = fft(y). Due to circulant property, Y = diag(fft(alpha)) * s + N.

4.5 SER Calculation with Known Channels

Assuming perfect channel knowledge, equalize: s_est = Y ./ fft(alpha, N). Then detect and compute SER. Average over realizations.

4.6 Plotting SER vs SNR

Plot SER vs SNR for OFDM. Compare with non-OFDM case to see improvement.

Bonus Tasks: Channel Estimation and Coding

B1: Channel Estimation with Pilots

Insert known pilot symbols at specific subcarriers. Estimate channel at pilot positions using least squares: H_pilot = Y_pilot ./ s_pilot. Interpolate to obtain full channel estimate. Use this for detection and compute SER.

B2: Repetition Coding with Rate 1/3

Repeat each symbol three times across subcarriers. At receiver, average the three received versions before detection. Plot SER; the slope indicates diversity order. Estimate diversity order from the slope of log(SER) vs log(SNR).

B3: Adaptive Subcarrier Disabling

Identify worst subcarriers (e.g., those with low SNR) and disable them. Increase power or rate on good subcarriers. Simulate and compare SER with baseline OFDM.

Conclusion

This tutorial walked you through simulating OFDM systems in MATLAB, from channel modeling to performance evaluation. By experimenting with parameters and bonus tasks, you gain deeper insight into how OFDM mitigates frequency-selective fading. These skills are directly applicable to modern wireless standards like 5G NR and Wi-Fi 7.

References and Further Reading

  • ELEC0086 Lecture Notes on OFDM
  • MATLAB Documentation: poissrnd, fft, ifft
  • Proakis, J. G., Digital Communications