%% Synchronize and Demodulate Transmission Containing PSCCH DM-RS
% Synchronize and demodulate a transmission that has been delayed by five samples. The transmission contains PSCCH demodulation reference signal (DM-RS) symbols that are used when estimating the waveform timing offset.
% Create a UE configuration specifying 15 resource blocks, a normal cyclic prefix, and a PRBSet of 1.

ue = struct('NSLRB',15,'CyclicPrefixSL','Normal','PRBSet',1);

%
% Create a resource grid and modulate the waveform containing PSCCH DM-RS symbols.

txgrid = lteSLResourceGrid(ue);
txgrid(ltePSCCHDRSIndices(ue)) = ltePSCCHDRS;
txwaveform = lteSLSCFDMAModulate(ue,txgrid);

%
% Add a time delay of five samples.

rxwaveform = [zeros(5,1); txwaveform];

%
% Calculate the timing offset in samples.

offset = lteSLFrameOffsetPSCCH(ue,rxwaveform)

%
% Correct the timing offset and demodulate the received waveform.

rxGrid = lteSLSCFDMADemodulate(ue,rxwaveform(1+offset:end));

% Copyright 2012 The MathWorks, Inc.