%% Generate PUSCH PT-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 PUSCH configuration object with codebook-based transmission and enable the PT-RS configuration. Set the number of antenna ports to 4 and transform precoding to 0. When transform precoding is 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.EnablePTRS = 1;

% Create a PUSCH phase tracking reference signal (PT-RS) configuration object with specified properties.

ptrs = nrPUSCHPTRSConfig;
ptrs.TimeDensity = 2;
ptrs.FrequencyDensity = 4;
ptrs.REOffset = '11';

% Assign the PUSCH PT-RS configuration object to PTRS property of PUSCH configuration object.

pusch.PTRS = ptrs;

% Generate PUSCH PT-RS indices in subscript form

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

% Copyright 2019 The MathWorks, Inc.