In OFDM (Orthogonal Frequency Division Multiplexing), we transmit multiple orthogonal subcarriers simultaneously. Since the subcarriers are orthogonal, they do not interfere with each other, which is one of the main advantages of OFDM. Practically, OFDM converts a wideband signal into multiple narrowband orthogonal subcarriers.
For typical wireless communication, if the signal bandwidth (or symbol duration) exceeds the coherence bandwidth of the channel, the signal experiences frequency-selective fading. Fading distorts the signal, making it difficult to recover the original information. By using OFDM, we transmit the same wideband signal across multiple orthogonal narrowband subcarriers, reducing the effect of fading.
For example, if we want to transmit a signal of bandwidth 1024 kHz, we can divide it into N = 8 subcarriers. Each subcarrier is then spaced by:
Let N be the number of subcarriers. The subcarrier frequencies are centered around zero and range from:
So for our example, the subcarrier frequencies are:
By using OFDM with these orthogonal subcarriers, the communication system becomes robust to frequency-selective fading, and the overall wideband signal can be transmitted and recovered smoothly.
MATLAB Code for Theoretical OFDM Sinc Spectra (Orthogonal)
clc;
clear;
close all;
% Parameters
N = 8;
fs = 1024; % Sampling frequency
T = N/fs;
delta_f = fs/N;
f = linspace(-fs/2, fs/2, 1024);
figure;
hold on;
grid on;
for k = -N/2:N/2-1
fk = k * delta_f;
S = T * sinc(T*(f - fk));
plot(f, abs(S),'LineWidth',1.5);
end
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Theoretical OFDM Sinc Spectra (Orthogonal)');
MATLAB Code for Simulated OFDM Spectrum (Orthogonal Case)
clc;
clear;
close all;
% ===============================
% PARAMETERS
% ===============================
N = 8; % Number of subcarriers
fs = 1000; % Sampling frequency (Hz)
Nfft = 1024; % FFT size for smooth spectrum
Ts = 1/fs;
T = N/fs; % OFDM symbol duration (IMPORTANT)
delta_f = fs/N; % Subcarrier spacing (Fs/N)
fprintf('Subcarrier spacing = %.2f Hz\n', delta_f);
% ===============================
% TRANSMITTER
% ===============================
% Generate random QPSK data
data = randi([0 3],1,N);
symbols = exp(1j*pi/2*data); % QPSK mapping
% IFFT (Discrete OFDM generation)
ofdm_time = ifft(symbols, N);
% Time axis
t = (0:N-1)*Ts;
% ===============================
% SPECTRUM VISUALIZATION
% ===============================
OFDM_spectrum = fftshift(fft(ofdm_time, Nfft));
f_axis = linspace(-fs/2, fs/2, Nfft);
figure;
subplot(3,1,1)
stem(0:N-1, abs(symbols),'filled')
title('Transmitted QPSK Symbols (Frequency Domain)')
xlabel('Subcarrier Index')
ylabel('Magnitude')
grid on;
subplot(3,1,2)
plot(f_axis, abs(OFDM_spectrum)/max(abs(OFDM_spectrum)))
title('OFDM Spectrum (Orthogonal Case)')
xlabel('Frequency (Hz)')
ylabel('Normalized Magnitude')
grid on;
% ===============================
% RECEIVER (NO ICI)
% ===============================
received_symbols = fft(ofdm_time, N);
subplot(3,1,3)
stem(0:N-1, abs(received_symbols),'r','filled')
title('Recovered Symbols (Perfect Orthogonality)')
xlabel('Subcarrier Index')
ylabel('Magnitude')
grid on;
% ===============================
% PART 2: INTRODUCE FREQUENCY OFFSET (ICI)
% ===============================
freq_offset = 20; % 20 Hz frequency offset
ofdm_offset = ofdm_time .* exp(1j*2*pi*freq_offset*t);
received_ici = fft(ofdm_offset, N);
figure;
subplot(2,1,1)
stem(0:N-1, abs(received_symbols),'filled')
title('Recovered Symbols (No ICI)')
xlabel('Subcarrier Index')
ylabel('Magnitude')
grid on;
subplot(2,1,2)
stem(0:N-1, abs(received_ici),'r','filled')
title('Recovered Symbols With Frequency Offset (ICI Present)')
xlabel('Subcarrier Index')
ylabel('Magnitude')
grid on;
