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

ue = struct('NSLRB',50,'CyclicPrefixSL','Normal','PRBSet',5);

cec = struct('FreqWindow',7,'TimeWindow',1,'InterpType','cubic', ...
    'PilotAverage','UserDefined');

%
% Create the subframe grid, control channel, and indices for a subframe. Populate the subframe with PSCCH symbols.

subframe = lteSLResourceGrid(ue);

[pscchIndices,pscchInfo] = ltePSCCHIndices(ue);
pscchSymbols = ltePSCCH(randi([0 1],pscchInfo.G,1));

subframe(pscchIndices) = pscchSymbols;

%
% Create the control DM-RS and indices. Add the PSCCH DM-RS symbols to the subframe.

subframe(ltePSCCHDRSIndices(ue)) = ltePSCCHDRS;

%
% Perform sidelink SC-FDMA modulation.

txWaveform = lteSLSCFDMAModulate(ue,subframe);

%
% No channel impairment is applied, so set the received waveform equal to the transmit waveform. Perform sidelink SC-FDMA demodulation and channel estimation.

rxWaveform = txWaveform;

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

% Copyright 2012 The MathWorks, Inc.