Main Content


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.


    collapse all

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

    Input Arguments

    collapse all

    Model name, specified as a character vector or string. The model must be open.

    Example: 'sdoAircraft'

    Data Types: char | string

    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.

    Example: p_des

    Data Types: char | string

    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.

    Example: p_des


    If param_des is a character vector or string, you must specify value.

    Version History

    Introduced in R2011b