%% Estimate Channel and Noise Using PSCCH DM-RS
% Estimate the channel characteristics and noise power spectral density given the PSCCH-received resource grid containing PSCCH DM-RS symbols.
% Create structures defining UE-specific and channel estimation configuration settings.

ue = struct('NSLRB',25,'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);

%
% Add noise to impair the channel. Perform sidelink SC-FDMA demodulation and channel estimation. View the noise estimate.

rxWaveform = awgn(txWaveform,15,'measured');

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

% Copyright 2012 The MathWorks, Inc.