%% Generate NPUSCH Symbols for Bundle
% Generate NPUSCH symbols on a slot-by-slot basis for transmitting a bundle comprising one resource unit, 16 slots, and two codeword repetitions.
% Configure UE-specific settings.

ue = struct('NNCellID',0,'NBULSubcarrierSpacing','3.75kHz');

% Specify a channel transmission configuration.

chs = struct('NPUSCHFormat','Data','NRUsc',1,'NRep',2,'NBULSubcarrierSet',17, ...
    'NRU',1,'NULSlots',16,'Modulation','BPSK','RNTI',0);

% Generate a codeword of bits.

[~,info] = lteNPUSCHIndices(ue,chs);
cwLen = info.G;
cw = ones(cwLen,1);

% Specify the initial encoder state as an empty structure, indicating the start of a bundle.

stateIn = struct();

% Generate NPUSCH symbols for bundle transmission.

for SlotIdx = 0:(chs.NRep*chs.NRU*chs.NULSlots-1)
    ue.NSlot = SlotIdx;
    [sym,stateOut] = lteNPUSCH(ue,chs,cw,stateIn);
    stateIn = stateOut;
end

% Confirm that the transmission reaches the end of the bundle.

disp(stateOut.EndOfTx)

% Copyright 2019 The MathWorks, Inc.