This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Package: sdo

Set design variable value in model




sdo.setValueInModel(modelname,param_des) sets the value of a parameter in an open Simulink® model to the Value property of the design variable param_des .

You generally use this command to update the Simulink model with optimized parameter values.

sdo.setValueInModel(modelname,param_des,value) sets the parameter to the value you specify.

Input Arguments


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


Design variable, specified as:

  • A param.Continuous object for one variable or a vector of objects for multiple variables, created using sdo.getParameterFromModel. Specify param_des as a param.Continuous object if you have a variable in a referenced model.

  • Character vector or string for one variable. For multiple variables, specify as cell array of character vectors or a string array. For example, {modelname,'Kp','Ki'}.

    Also specify 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 sdo.setValueInModel('TopLevelModel','Controller:Ki',value).

If Ki is a model argument in a referenced model, provide block path from top-level model as follows, sdo.setValueInModel('TopLevelModel','TopLevelModel/ControlBlock:Ki',value). Here, ControlBlock is the block name in the referenced model.


Value to set for the design variable.

Use a cell array with the same number of elements as the number of variables in param_des for setting values of multiple design variables. value is required if param_des is a character vector or string.


Change the design variable value in a model.

p_des = sdo.getParameterFromModel('sldo_model1_stepblk','Kp');
p_des.Value = 1.1*p_des.Value;

The value of Kp is set to the Value property of p_des.

Introduced in R2011b