%% Model PUCCH Format 2
% This example shows how to model the control region used in an LTE uplink subframe and its channel structure. It demonstrates how you create the physical uplink control channel (PUCCH) format 2 structures and map the generated symbols to a resource grid.
% Specify user equipment (UE) settings in a structure, ue. Many of the functions used in this example require a subset of these settings.

ue.NCellID = 10;
ue.CyclicPrefixUL = 'Normal';
ue.NSubframe = 0;
ue.Hopping = 'Off';
ue.NULRB = 9;
ue.RNTI = 77;

%
% Configure the PUCCH Format 2. In addition to the UE settings specified in ue, you must define parameters related to the physical channel to generate the PUCCH Format 2.

pucch2.ResourceIdx = 36;
pucch2.ResourceSize = 3;
pucch2.CyclicShifts = 6;

%
% Generate the UCI message from the CQI bits.

cqi = [0 1 1 0 0 1];
codedCQI = lteUCIEncode(cqi);

%
% Generate the PUCCH Format 2 symbols by calling the ltePUCCH2 function, providing the UE settings, PUCCH configuration, and UCI message as input arguments.

pucch2Sym = ltePUCCH2(ue,pucch2,codedCQI);

%
% Generate the PUCCH Format 2 indices by calling the ltePUCCH2Indices function. You can use these generated indices to map the PUCCH complex symbols to the subframe resource grid. This function requires the same input argument structures as the ltePUCCH2 function.

pucch2Indices = ltePUCCH2Indices(ue,pucch2);

%
% Generate the PUCCH Format 2 demodulation reference signals (DRS) by calling the ltePUCCH2DRS function. This function requires the same input argument structures as the ltePUCCH2 and ltePUCCH2Indices functions. Since no HARQ bits are transmitted, specify an empty vector as the third input argument of the function.

pucch2DRSSym = ltePUCCH2DRS(ue,pucch2,[]);

%
% Generate the PUCCH Format 2 DRS indices by calling the ltePUCCH2DRSIndices function. You can use these indices to map the DRS to the subframe resource grid.

pucch2DRSIndices = ltePUCCH2DRSIndices(ue,pucch2);

%
% Generate the subframe resource grid by calling the lteULResourceGrid function. This function creates an empty resource grid for one subframe.

subframe = lteULResourceGrid(ue);

%
% Map the PUCCH Format 2 symbols and DRS to the resource grid using the generated indices.

subframe(pucch2Indices) = pucch2Sym;
subframe(pucch2DRSIndices) = pucch2DRSSym;

% Copyright 2012 The MathWorks, Inc.