%% Model UL-SCH and PUSCH
% This example shows how to construct the physical uplink shared channel (PUSCH). It demonstrates how to generate a transport block, perform uplink shared channel (UL-SCH) coding to create a codeword, perform physical channel coding to create the physical channel, and map the complex symbols to the resource grid.
% Specify user-equipment (UE) settings in the structure ue. Many of the functions used in this example require a subset of these fields.

ue.NULRB = 9;
ue.NSubframe = 0;
ue.NCellID = 10;
ue.RNTI = 1;
ue.CyclicPrefixUL = 'Normal';
ue.Hopping = 'Off';
ue.SeqGroup = 0;
ue.CyclicShift = 0;
ue.Shortened = 0;

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

pusch.PRBSet = (0:5).';
pusch.Modulation = 'QPSK';
pusch.RV = 0;
pusch.DynCyclicShift = 0;

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

subframe = lteULResourceGrid(ue);

%
% Generate the UL-SCH message by calling the lteULSCH function, providing the transport block data trblk, UE-specific structure ue, and channel-specific structure pusch as input arguments.

trblk = round(rand(1,504));
cw = lteULSCH(ue,pusch,trblk);

%
% Generate the PUSCH symbols by calling the ltePUSCH function, providing the UE settings, PUSCH configuration, and codeword as input arguments.

puschSymbols = ltePUSCH(ue,pusch,cw);

%
% Generate the PUSCH indices by calling the ltePUSCHIndices function. You can use these generated indices to map the PUSCH complex symbols to the subframe resource grid. This function requires the same input argument structures as the ltePUSCH function.

puschIndices = ltePUSCHIndices(ue,pusch);

%
% Generate the PUSCH DRS symbols by calling the ltePUSCHDRS function. This function requires the same input argument structures as the ltePUSCH function.

drsSymbols = ltePUSCHDRS(ue,pusch);

%
% Generate the PUSCH DRS indices by calling the ltePUSCHDRSIndices function. You can use these indices to map the DRS to the subframe resource grid.

drsIndices = ltePUSCHDRSIndices(ue,pusch);

%
% Map the PUSCH symbols and DRS to the resource grid using the generated indices.

subframe(puschIndices) = puschSymbols;
subframe(drsIndices) = drsSymbols;

% Copyright 2012 The MathWorks, Inc.