%% Estimate Channel Using PSBCH DM-RS and Default CE Settings
% Estimate the channel characteristics given the PSBCH-received resource grid containing PSBCH DM-RS symbols. Use the default channel estimation configuration method, as defined in TS 36.101, Annex F.
%
%% Create Parameter Structure
% Define UE-specific settings in a parameter structure.

ue = struct('NSLRB',50,'CyclicPrefixSL','Normal','NSLID',1);

%
%% Populate Subframe with PSBCH Symbols
% Create the subframe grid and indices for the subframe. Create broadcast channel and demodulation reference symbols and populate the subframe.

subframe = lteSLResourceGrid(ue);
psbchIndices = ltePSBCHIndices(ue);
psbchdmrsIndices = ltePSBCHDRSIndices(ue);
psbchSymbols = ltePSBCH(ue,lteSLBCH(ue,zeros(40,1)));
subframe(psbchIndices) = psbchSymbols;
subframe(psbchdmrsIndices) = ltePSBCHDRS(ue); 

%
%% Estimate Channel Characteristics
% Use the received resource grid containing PSBCH 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 = lteSLChannelEstimatePSBCH(ue,rxGrid);

% Copyright 2012 The MathWorks, Inc.