%% Transmit Multiple Subframes over Fading Channel
% Transmit a number of subframes through a fading channel using a for-loop.
% Define the channel configuration structure.

chcfg.DelayProfile = 'EPA';
chcfg.NRxAnts = 1;
chcfg.DopplerFreq = 5;
chcfg.MIMOCorrelation = 'Low';
chcfg.Seed = 1;
chcfg.InitPhase = 'Random';
chcfg.ModelType = 'GMEDS';
chcfg.NTerms = 16;
chcfg.NormalizeTxAnts = 'On';
chcfg.NormalizePathGains = 'On';

%
% Define the transmission waveform configuration structure, initialized to RMC 'R.10' and one subframe.

rmc = lteRMCDL('R.10');
rmc.TotSubframes = 1;

%
% Within a for-loop, generate ten subframes, one subframe at a time.
% Outside the for-loop, define delay, which accounts for a combination of implementation delay and channel delay spread.
% Set the subframe number and initialize the subframe start time, allocating 1 ms per subframe.
% Generate a transmit waveform.
% Initialize the number of transmit antennas and the waveform sampling rate.
% Send the waveform through the channel. Append delay zeros to the generated waveform prior to channel filtering.

delay = 25;
for subframeNumber = 0:9
    
    rmc.NSubframe = mod(subframeNumber,10);
    chcfg.InitTime = subframeNumber/1000;
    
    [txWaveform,txGrid,info] = lteRMCDLTool(rmc,[1;0;1;1]);
    
    numTxAnt = size(txWaveform,2);
    chcfg.SamplingRate = info.SamplingRate;
    
    rxWaveform = lteFadingChannel(chcfg,[txWaveform; zeros(delay,numTxAnt)]);
end

% Copyright 2012 The MathWorks, Inc.