%% Generate OFDM Modulated Waveform for Extended Cyclic Prefix
% Generate a waveform by performing OFDM modulation of a resource array that contains physical downlink shared channel (PDSCH) demodulation reference signal (DM-RS) symbols.
% Set carrier configuration parameters, specifying a subcarrier spacing of 60 kHz.

scs = 60;
carrier = nrCarrierConfig('SubcarrierSpacing',scs);

% Generate PDSCH DM-RS symbols and indices.

p = 2;
pdsch = nrPDSCHConfig('NumLayers',p);
sym = nrPDSCHDMRS(carrier,pdsch);
ind = nrPDSCHDMRSIndices(carrier,pdsch);

% Create a carrier resource array containing the PDSCH DM-RS symbols.

grid = nrResourceGrid(carrier,p);
grid(ind) = sym;

% Generate an OFDM modulated waveform, specifying the subcarrier spacing, initial slot number, and cyclic prefix type. Display the OFDM information.

initNSlot = carrier.NSlot;
cpl = 'extended';
[waveform,info] = nrOFDMModulate(grid,scs,initNSlot,'CyclicPrefix',cpl);
disp(info)

% Copyright 2020 The MathWorks, Inc.