How does ofdmChannelResponse function really work ?

3 次查看(过去 30 天)
I have written this code and I want to know what exactly happens under the hood of the ofdmChannelResponse block and how can I replicate it manually in my code ? In other words, what kind of mathematics happens to obtain hest given channel pathgains, path filters, nfft and CP size ?
%% Parameters
nFFT = 128; % Number of FFT bins
cpSize = 32; % CP length
M_mod = 4; % Size of QAM constellation
M_bits = log2(M_mod); % Bits per QAM symbol
N_bits_perfram = nFFT * M_bits;
SNR_dB = 0:3:30;
Nf = 1e4; % Number of Monte‐Carlo trials per SNR
delta_f = 15e3; % 15 kHz subcarrier spacing
fs = nFFT * delta_f; % Sampling Frequency (1.92 MHz)
pathDelays = [0 50 120 200 230 500 1600 2300 5000]*1e-9;
delaySamples = round(pathDelays * fs);
P = length(pathDelays);
avgPathGains_dB = [-1 -1 -1 0 0 0 -3 -5 -7]; % (dB)
%% Doppler shifts to sweep
doppler = [0, 100];
numD = length(doppler);
fd1 = doppler(1);
fd2 = doppler(2);
%% Initialize BER accumulators for this Doppler
BER = zeros(1, length(SNR_dB));
%% Create Rayleigh channel object (with current fd)
rayleighchan = comm.RayleighChannel( ...
'SampleRate', fs, ...
'PathDelays', pathDelays, ...
'AveragePathGains', avgPathGains_dB, ...
'MaximumDopplerShift', fd1, ...
'PathGainsOutputPort', true);
chaninfo = info(rayleighchan);
coeff = chaninfo.ChannelFilterCoefficients;
%% Loop over SNR points
for q = 1:length(SNR_dB)
snr = SNR_dB(q);
for i = 1:Nf
%-----------------------------------------
% 1) Data Generation
%-----------------------------------------
data_info_bit = randi([0,1], nFFT*M_bits, 1);
data_c = bi2de(reshape(data_info_bit, nFFT, M_bits));
qamTx = qammod(data_c, M_mod, 'gray','UnitAveragePower', true);
%-----------------------------------------
% 2) OFDM Transmitter
%-----------------------------------------
txout = ofdmmod(qamTx, nFFT, cpSize);
%-----------------------------------------
% 4) Fading Channel + AWGN for OFDM path
%-----------------------------------------
[chanOut, pathGains] = rayleighchan(txout);
[RXIN_noisy, nvar] = awgn(chanOut, snr,"measured");
%-----------------------------------------
% 6) Channel Estimation (OFDM)
%-----------------------------------------
hest = ofdmChannelResponse(pathGains, coeff, nFFT, cpSize);
% Demodulate OFDM
rxsym = ofdmdemod(RXIN_noisy, nFFT, cpSize);
%-----------------------------------------
% 8) MMSE Equalization (OFDM)
%-----------------------------------------
G_mmse = conj(hest) ./ (abs(hest).^2 + nvar);
X_hat = G_mmse .* rxsym;
%-----------------------------------------
% 11) QAM Demapping + BER Accumulation (OFDM)
%-----------------------------------------
data_demapping = qamdemod(X_hat, M_mod, 'gray','UnitAveragePower', true);
data_info_est1 = reshape(de2bi(data_demapping, M_bits), nFFT*M_bits, 1);
BER(q) = BER(q) + sum(xor(data_info_est1, data_info_bit));
end % end Monte Carlo loop Nf
end % end SNR loop
%% Normalize errors to obtain BER for this Doppler
ber = BER ./ (N_bits_perfram * Nf);
  2 个评论
dpb
dpb 2025-7-18
which -all ofdmChannelResponse
/MATLAB/toolbox/comm/comm/ofdmChannelResponse.m
is an m-file, you can go see what is under the hood, at least until it drops into either builtin or p-code functions, if it isn't all in the m-file.
Normally, TMW does provide links to supporting papers in the Algorithms section but it seems they didn't here. But, that's what comes with the proprietary language; they can document only what they feel like doing keeping internals hidden either for what may be considered competitive advantages or simply lack of resources to put more into the documenattion or just an oversight.
Seyyed Erfan
Seyyed Erfan 2025-7-23
I could see the code for the ofdmChannelResponse and it is more clear now how it works under the hood.
Thanks for your comment.

请先登录,再进行评论。

回答(1 个)

Ronit
Ronit 2025-7-23
The "ofdmChannelResponse" function estimates the OFDM channel frequency response ("hest") for each subcarrier, using:
  • pathGains: Instantaneous path amplitudes from the multipath fading model.
  • pathFilters: Channel filter coefficients (impulse response shaping).
  • nFFT and cpSize: The FFT and cyclic prefix sizes of the OFDM system.
You can replicate the function by:
  1. Rebuilding the impulse response from "pathGains * coeff".
  2. Zero-padding to "nFFT" length.
  3. Using "fft(h, nFFT)" to get "hest".
This helps simulate perfect channel knowledge for MMSE equalization.
Please refer to the documentation as well: https://www.mathworks.com/help/comm/ref/ofdmchannelresponse.html

类别

Help CenterFile Exchange 中查找有关 Downlink Channels 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by