%% Estimate Channel Using PSSCH DM-RS
% Estimate the channel characteristics given the PSSCH-received resource grid containing PSSCH DM-RS symbols. The default channel estimation configuration is adjusted.
%
%% Create parameter structures
% Define UE-specific settings and channel estimation configuration settings in parameter structures.

ue = struct('NSLRB',50,'CyclicPrefixSL','Normal','NSAID',255, ...
           'Modulation','QPSK','NSubframePSSCH',0,'PRBSet',(30:39)');
cec = struct('FreqWindow',7,'TimeWindow',1,'InterpType','cubic', ...
            'PilotAverage','UserDefined');

%
%% Populate a subframe with PSSCH symbols
% Create the subframe grid and indices for the subframe. Create shared channel and demodulation reference signal (DM-RS) symbols. Populate the subframe with shared channel and DM-RS symbols.

subframe = lteSLResourceGrid(ue);
[psschIndices,psschInfo] = ltePSSCHIndices(ue);

psschSymbols = ltePSSCH(ue,zeros(psschInfo.G,1));
subframe(psschIndices) = psschSymbols;

subframe(ltePSSCHDRSIndices(ue)) = ltePSSCHDRS(ue); 

%
%% Estimate the channel characteristics
% Use the received resource grid containing PSSCH DM-RS symbols to estimate the channel characteristics.
% Perform sidelink SC-FDMA modulation.
% No channel impairment is applied, so set the received waveform equal to the transmit waveform.
% Perform sidelink SC-FDMA demodulation and channel estimation.

txWaveform = lteSLSCFDMAModulate(ue,subframe);

rxWaveform = txWaveform;

rxGrid = lteSLSCFDMADemodulate(ue,rxWaveform);
hest = lteSLChannelEstimatePSSCH(ue,cec,rxGrid);

% Copyright 2012 The MathWorks, Inc.