%% Synchronize and Demodulate Using PUCCH Format 1 DM-RS
% Synchronize and demodulate a transmission that has been delayed by four samples using the PUCCH format 1 demodulation reference signal (DM-RS) symbols.
% Initialize configuration structures (ue and pucch1).

ue = struct('NULRB',6,'NCellID',0,'NSubframe',0,'Hopping','Off');
ue.CyclicPrefixUL = 'Normal';
ue.NTxAnts = 1;

pucch1 = struct('ResourceIdx',0);
pucch1.CyclicShifts = 0;
pucch1.DeltaShift = 1;
pucch1.ResourceSize = 0;

%
% On the transmit side, populate reGrid, generate waveform, and insert a delay of four samples.

reGrid = lteULResourceGrid(ue);
reGrid(ltePUCCH1DRSIndices(ue,pucch1)) = ltePUCCH1DRS(ue,pucch1);
waveform = lteSCFDMAModulate(ue,reGrid);
tx = [zeros(4,1); waveform];

%
% On the receive side, perform synchronization using the PUCCH format 1 DM-RS symbols for the time-domain waveform and demodulate adjusting for the frame timing estimate. Show estimated frame timing offset.

fOffset = lteULFrameOffsetPUCCH1(ue,pucch1,tx)
rxGrid = lteSCFDMADemodulate(ue,tx(1+fOffset:end));

% Copyright 2012 The MathWorks, Inc.