function HTLinkModelWLANExample_params(block)
%HTLinkModelWLANExample_params Featured example helper function

%   Copyright 2017-2019 The MathWorks, Inc.

    % Set simulation parameters
    simParams = struct;
    simParams.channelBandwidth = get_param(block,'channelBandwidth');    
    simParams.psduLength = evalin('base',get_param(block,'psduLength'));
    simParams.spatialMapping = get_param(block,'spatialMapping');
    simParams.numRx = str2double(get_param(block,'numRx'));
    simParams.numTx = str2double(get_param(block,'numTx'));
    simParams.idleTime = 28e-6; % DIFS
    simParams.numSTS = str2double(get_param(block,'numSTS'));
    
    % MCS number is the first part of the string
    strSections = strsplit(get_param(block,'mcs'));
    simParams.mcs = str2double(strSections{1});
    
    % Validate configuration so we throw any error in the dialog
    cfgHT = wlanHTConfig('MCS',simParams.mcs,'ChannelBandwidth',simParams.channelBandwidth,'NumTransmitAntennas',simParams.numTx,'NumSpaceTimeStreams',simParams.numSTS,'PSDULength',simParams.psduLength,'SpatialMapping',simParams.spatialMapping);
    ind = wlanFieldIndices(cfgHT);
    ofdmInfo = wlanHTOFDMInfo('HT-Data',cfgHT);
    numDataSymbols = double(ind.HTData(2)-ind.HTData(1)+1)/(ofdmInfo.FFTLength+ofdmInfo.CPLength);
    
    % Set parameters for sizing signals
    ofdmInfo = wlanHTOFDMInfo('HT-Data',cfgHT);
    simParams.Nsd = numel(ofdmInfo.DataIndices); % Number of data carrying subcarriers
    simParams.Nst = ofdmInfo.NumTones;           % Number of occupied subcarriers
    simParams.numSym = numDataSymbols;
    simParams.numSS = floor(cfgHT.MCS/8)+1;
    simParams.numSamples = double(ind.HTData(2))+ceil(simParams.idleTime*wlanSampleRate(cfgHT));
    simParams.sampleRate = wlanSampleRate(cfgHT);
    
    % Output parameters
    assignin('base', 'simParams', simParams);
end
