function PDSCHThroughputSimulinkExample_params(block)
%PDSCHThroughputSimulinkExample_params Featured example helper function

%   Copyright 2017 The MathWorks, Inc.

    % Set simulation parameters
    simParams = struct;
    InitParams = struct;
    
    simParams.snrdb = evalin('base',get_param(block,'SNR'));
    
    InitParams.txMode = get_param(block,'txMode');
    
    InitParams.NDLRB = evalin('base',get_param(block,'ndlrb'));
    InitParams.PDSCH.TargetCodeRate = evalin('base',get_param(block,'codeRate'));
    MaskStruct =(get_param(block,'MaskWSvariables'));
    InitParams.PDSCH.PRBSet = MaskStruct(4).Value;
    
    switch InitParams.txMode
    % Single antenna (Port0) mode (TM1)
    case 'TM1'   
        InitParams.PDSCH.TxScheme = 'Port0';
        InitParams.PDSCH.DCIFormat = 'Format1';
        InitParams.CellRefP = 1;
        InitParams.PDSCH.Modulation = '16QAM';
    
    % Transmit diversity mode (TM2)
    case 'TM2'
        InitParams.PDSCH.TxScheme = 'TxDiversity';
        InitParams.PDSCH.DCIFormat = 'Format1';
        InitParams.CellRefP = 2;
        InitParams.PDSCH.Modulation = '16QAM';
        InitParams.PDSCH.NLayers = 2;

    % CDD mode (TM3)
    case 'TM3'
        InitParams.PDSCH.TxScheme = 'CDD';
        InitParams.PDSCH.DCIFormat = 'Format2A';
        InitParams.CellRefP = 2;
        InitParams.PDSCH.Modulation = {'16QAM', '16QAM'};
        InitParams.PDSCH.NLayers = 2;
    
    end
    
    % Set other fields applying to all TMs
    InitParams.TotSubframes = 1; % Generate one subframe at a time
    InitParams.PDSCH.CSI = 'On'; % Soft bits are weighted by CSI
    
    % Create structure for eNodeB parameters
    simParams.enb = struct;
    simParams.enb = lteRMCDL(InitParams);
    simParams.enb.PDSCH.Modulation = char(simParams.enb.PDSCH.Modulation);
    simParams.enb.PDSCH.RVSeq = 0; % Disable HARQ
    
    % Calculate lineal SNR including compensation for downlink power
    % allocation
    simParams.snr = 10^((simParams.snrdb - simParams.enb.PDSCH.Rho)/20);
    
    % Initial offset for the channel estimator
    simParams.offset = 0;
    
    % OFDM simbol to get the sampling rate and Nfft
    ofdmInfo = lteOFDMInfo(simParams.enb);
    simParams.Nfft = ofdmInfo.Nfft;
    simParams.SamplingRate =  ofdmInfo.SamplingRate;
    
    % Gridsize is a three element vector [K; L; P]: where K = no of subcarriers,
    % L = no of OFDM symbols and P = no of transmit antennas
    simParams.gridSize = lteDLResourceGridSize(simParams.enb);  
    
    % Configure channel
    simParams.cfg = struct;                                                     % Channel config structure
    simParams.cfg.Seed = evalin('base',get_param(block,'seed'));                % Channel seed
    simParams.cfg.NRxAnts = evalin('base',get_param(block,'rxAnts'));           % Receive antennas
    simParams.cfg.DelayProfile = get_param(block,'delaypro');                   % Delay profile
    simParams.cfg.DopplerFreq = evalin('base',get_param(block,'dopp'));         % Doppler frequency in Hz
    simParams.cfg.MIMOCorrelation = get_param(block,'MIMOcorr');                % Multi-antenna correlation
    simParams.cfg.NTerms = 16;                                                  % Oscillators used in fading model
    simParams.cfg.ModelType = get_param(block,'modeltype');                     % Rayleigh fading model type
    simParams.cfg.InitPhase = 'Random';                                         % Random initial phases
    simParams.cfg.NormalizePathGains = get_param(block,'NormalizePathGains');   % Normalize delay profile power
    simParams.cfg.NormalizeTxAnts = 'On';                                       % Normalize for transmit antennas 
    simParams.cfg.InitTime = 0;                                                 
    simParams.cfg.SamplingRate = ofdmInfo.SamplingRate;
    
    % Set the random number to ensure repeatability 
    rng('default');
    
    % Configure channel estimator
    simParams.cec.PilotAverage = get_param(block,'pilotAvg');                   % Type of pilot symbol averaging
    simParams.cec.FreqWindow = evalin('base',get_param(block,'FreqWindow'));    % Frequency window size in REs
    simParams.cec.TimeWindow = evalin('base',get_param(block,'TimeWindow'));    % Time window size in REs
    simParams.cec.InterpType = get_param(block,'interType');                    % 2D interpolation type
    simParams.cec.InterpWindow = get_param(block,'interWindow');                % Interpolation window type
    simParams.cec.InterpWinSize = evalin('base',get_param(block,'interSize'));  % Interpolation window size
    
    % Get Model Time Step
    simParams.ModelTimeStep = evalin('base',get_param(bdroot,'FixedStep'));
    
    % Assign simParams to base workspace
    assignin('base', 'simParams', simParams);
    end