%% Perform HST Model Perfect DL Channel Estimation
% Perform perfect channel estimation for a high speed train (HST) propagation channel configuration in the downlink. Include time and frequency offsets in the channel estimation computation.
%% Configuration initialization
% Initialize configuration structures for eNodeB and HST propagation channel.

enb.NDLRB = 6;
enb.NCellID = 1;
enb.CyclicPrefix = 'Normal';
enb.CellRefP = 1;
enb.TotSubframes = 1;

hst.NRxAnts = 2;
hst.Ds = 100;
hst.Dmin = 500;
hst.Velocity = 200;
hst.DopplerFreq = 5.0;
hst.InitTime = 0.0;
hst.ModelType = 'GMEDS';
hst.NormalizeTxAnts = 'On';

%
%% Waveform processing
% Create waveform and add samples for channel delay.
% Pass through an HST channel, generating time-domain receiver samples.

[txwave,txgrid,rmcCfg] = lteRMCDLTool(enb,[1;0;0;1]);
txwave = [txwave; zeros(25,enb.CellRefP)];
hst.SamplingRate = rmcCfg.SamplingRate;
rxwave = lteHSTChannel(hst,txwave);

%
%% Determine timing and frequency offsets
% Use lteDLFrameOffset to estimate time offset.
% Account for the timing offset in the received waveform.
% Use lteFrequencyOffset to estimate frequency offset.

toffset = lteDLFrameOffset(enb,rxwave)
rxwave = rxwave(1+toffset:end,:);
foffset = lteFrequencyOffset(enb,rxwave)

%
%% Demodulation and perfect channel estimation
% Demodulate rxwave to generate frequency-domain receiver data in rxgrid.
% Equalize with perfect channel estimate using time and frequency offsets.

rxgrid = lteOFDMDemodulate(enb,rxwave);
hest = lteDLPerfectChannelEstimate(enb,hst,[toffset,foffset]);
sizeH = size(hest)
recoveredgrid = rxgrid./hest;

% Copyright 2012 The MathWorks, Inc.