%% Demodulate OFDM Waveform with Specified Sample Rate
% Recover a transmitted resource array that contains sounding reference signals (SRSs) and spans an entire frame by demodulating an OFDM waveform.
% Set carrier configuration parameters, specifying a subcarrier spacing of 30 kHz and 24 resource blocks in the carrier resource array.

carrier = nrCarrierConfig('SubcarrierSpacing',30,'NSizeGrid',24);

% Configure SRS parameters, setting the slot periodicity and offset.

srs = nrSRSConfig('SRSPeriod',[4 0]);

% Get OFDM information for the specified carrier configuration.

info = nrOFDMInfo(carrier);

% Produce the frame resource array by creating and concatenating slot resource arrays.

frameGrid = [];
for nslot = 0:(info.SlotsPerFrame - 1)
    carrier.NSlot = nslot;
    slotGrid = nrResourceGrid(carrier);
    ind = nrSRSIndices(carrier,srs);
    sym = nrSRS(carrier,srs);
    slotGrid(ind) = sym;
    frameGrid = [frameGrid slotGrid];
end

% Generate the OFDM modulated waveform.

[txWaveform,~] = nrOFDMModulate(carrier,frameGrid);

% Pass the waveform through a simple channel.

H = 0.86;
waveform = txWaveform*H;

% Recover the carrier resource array by demodulating the received OFDM waveform, specifying the sample rate.

sr = info.SampleRate;
grid = nrOFDMDemodulate(carrier,waveform,'SampleRate',sr);

% Copyright 2020 The MathWorks, Inc.