# Perfect channel estimation for OFDM (via H=Y/X) in MATLAB

Despite using the same channel for convolution, each time I get a different estimated channel. Could you please tell me what I'm doing wrong? I want to demonstrate that I can estimate the same channel for different modulated signals (dataIn). The code is:

M=4;
nfft  = 512; % Number of data carriers
% Generate random data
dataIn = randi([0 M-1],1,nfft,1);
% Apply QPSK modulation
qamSig = qammod(dataIn,M,'UnitAveragePower',true);
% Taking IFFT
x_ifft1 = sqrt(nfft) * ifft(fftshift(qamSig),nfft);
% transmit through the channel
yhat2 = conv(x_ifft1,channelTD.');
% set the signal power to '1'
yhat2 = yhat2 / sqrt(var(yhat2));
% Taking FFT  OFDM for the perfect channel knowledge
y_fft2 = (1/sqrt(nfft))*(fft(fftshift(yhat2),nfft));
% Estimate Channel
EstimatedChannel = y_fft2 ./ qamSig;

%channelTD(401x1)

%%%%%%%%%%%%%%%%%%%%%Updated Code%%%%%%%%%%%%%%%%%%%%%%%%%%
M=4;
nfft  =512; % Number of data carriers
CP=16; %% Cyclic Prefix Lenght

% Generate random data
dataIn = randi([0 M-1],1,nfft,1);

% Apply QPSK modulation
qamSig = qammod(dataIn,M,'UnitAveragePower',true);

% Taking IFFT
x_ifft1 = sqrt(nfft) * ifft(fftshift(qamSig),nfft);

SignalWithCyclicPrefix = x_ifft1(:, end-CP+1:end);
SignalWithCyclicPrefix = [SignalWithCyclicPrefix x_ifft1];

% transmit through the channel
yhat2 = conv(SignalWithCyclicPrefix,channelTD.');

% set the signal power to '1'
%yhat2 = yhat2 / sqrt(var(yhat2));

% Removing Cyclic Prefix

% Taking FFT  OFDM for the perfect channel knowledge

% Estimate Channel
EstimatedChannel = y_fft2 ./ qamSig;


• Apologies for blowing away your edit. I didn't feel the channel data belonged in the question, so I moved it to a GitHub gist that I've linked to.
– Peter K.
Jun 2 at 13:29
• Thank you so much for your help! Jun 2 at 13:40
• You're welcome. Just trying to format your question so it's more likely to get an answer. Long questions tend to be avoided, particularly when they appear to be 90% code.
– Peter K.
Jun 2 at 13:43

% set the signal power to '1'
yhat2 = yhat2 / sqrt(var(yhat2));


Here you're effectively acting as if the channel gain was different, depending on your choice of data signals. So, you're not estimating the actual channel, but a varyingly scaled channel.

For you here, it doesn't matter, because QPSK is all the same power, no matter which symbols are actually sent. It's still a bug. Normalizing on the receive side: don't do it.

yhat2 = conv(x_ifft1,channelTD.');


your conv does a linear convolution, but the convolution theorem for the DFT makes point-wise multiplication in the frequency domain equivalent to cyclic convolution in time.

That's why OFDM systems use cyclic prefix (or zero-filled guard intervals). Your system is lacking that, so you should be getting the boundary effects caused by this.

• Hello Marcus, I appreciate your valuable feedback. I have made updates to my code based on your recommendations, as shown below. However, I am still encountering varying estimated channel results with each run. Jun 6 at 11:09

The convoluted channel is in time domain.

The estimated channel is in freq domain.

Compare channel in the same domain. Then it would be similar.

Take ifft of estimated channel, the answer should be equal to convoluted channel.