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:
Channel data moved here.. It comes from here.
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);
% Adding Cyclic Prefix
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
receivedSignal = yhat2(:,[CP+1:size(x_ifft1,2)+CP]);
% Taking FFT OFDM for the perfect channel knowledge
y_fft2 = (1/sqrt(nfft))*(fft(fftshift(receivedSignal),nfft));
% Estimate Channel
EstimatedChannel = y_fft2 ./ qamSig;