Main Content


Package: sdo

Get design variable value from model


param_value = sdo.getValueFromModel(modelname,param_des)


param_value = sdo.getValueFromModel(modelname,param_des) gets the value of a design variable in a Simulink® model. The model must be open.

Input Arguments


Simulink model name, specified as a character vector or string. For example, 'sldo_model1'.


Design variables, specified as:

  • A param.Continuous or param.Discrete object for one variable, or a vector of such parameter objects for multiple variables. To create these parameter objects, use sdo.getParameterFromModel.

  • Character vector or string for one variable. For multiple variables, specify as cell array of character vectors or a string array. For example, {'Kp','Ki'}. When you specify variables this way, you must also provide the value argument.

    If a parameter is in a referenced model, the variable name must include the path. For instance, if a parameter Ki is in a referenced model named Controller used in a top-level model, use param_des = 'Controller:Ki'.

    If Ki is a model argument in a referenced model, provide block path from top-level model as follows, param_des = 'TopLevelModel/ControlBlock:Ki'. Here, ControlBlock is the block name in the referenced model.

Output Arguments


Design variable value in the model.

A cell array for multiple variable values.


collapse all

p_value = sdo.getValueFromModel('sldo_model1_stepblk','Kp');

Alternatively, type:

p_des = sdo.getParameterFromModel('sldo_model1_stepblk','Kp');
p_value = sdo.getValueFromModel('sldo_model1_stepblk',p_des);

Version History

Introduced in R2011b