%% Generate PUSCH DM-RS Indices for Codebook-Based Transmission
% Create a carrier configuration object with default properties. This object corresponds to a 10 MHz carrier with 15 kHz subcarrier spacing.

carrier = nrCarrierConfig;

% Create a physical uplink shared channel (PUSCH) configuration object with specified properties. When transform precoding is set to 0, the waveform type is cyclic-prefix orthogonal frequency division multiplexing (CP-OFDM).

pusch = nrPUSCHConfig;
pusch.TransformPrecoding = 0;
pusch.TransmissionScheme = 'codebook';
pusch.NumAntennaPorts = 4;
pusch.TPMI = 0;

% Configure PUSCH demodulation reference signal (DM-RS) object with specified parameters.

pusch.DMRS.DMRSAdditionalPosition = 2;
pusch.DMRS.DMRSTypeAPosition = 2;
pusch.DMRS.DMRSPortSet = 3;
pusch.DMRS.NIDNSCID = 15;
pusch.DMRS.NSCID = 1;

% Generate DM-RS indices associated to PUSCH of subscript indexing form.

ind = nrPUSCHDMRSIndices(carrier,pusch,'IndexStyle','subscript')

% Copyright 2019 The MathWorks, Inc.