Main Content

setInputParameterByName

Update value of input parameter for a check

Since R2025a

    Description

    setInputParameterByName(cfgObj,checkInstanceID,nameOfInputParameter,valueOfInputParameter) updates the value defined by valueOfInputParameter of the input parameter specified by nameofInputParameter for the check checkInstanceID in the Model Advisor configuration accessed by the cfgObj object.

    Note

    If you modify an input parameter value in a value structure array, use jsonencode in the valueOfInputParameter input argument.

    example

    Examples

    collapse all

    Update the value of a specific input parameter of a check in a Model Advisor configuration.

    Create a Model Advisor configuration object.

    cfgObj = Advisor.Config;

    Load the myCustomFile.json file. Loading this file allows you to set the JSON file as an active configuration, providing you with access to edit it.

    loadConfig(cfgObj,"myCustomFile.json");

    Set the value of Follow links input parameter of the check mathworks.maab.db_0140 in the folder _SYSTEM_By Product_Simulink Check_Modeling Standards_JMAAB v5.1 Checks to off. You can obtain the check instance ID and the input parameters in the Model Advisor when you select the check mathworks.maab.db_0140.

    setInputParameterbyName(cfgObj,"_SYSTEM_By Product_Simulink Check_Modeling Standards_JMAAB  v5.1 Checks_mathworks.maab.db_0140","Follow links",off)
    

    Update the value of an input parameter that has a value struct.

    Create a Model Advisor configuration object.

    cfgObj = Advisor.Config;

    Load the myCustomFile.json file. Loading this file allows you to set the JSON file as an active configuration, providing you with access to edit it.

    loadConfig(cfgObj,"myCustomFile.json");

    Get the value of input parameter Block type and parameters to check against defaults of the check mathworks.maab.db_0140 in the folder _SYSTEM_By Product_Simulink Check_Modeling Standards_JMAAB v5.1 Checks. You can obtain the check instance ID and the input parameter names in the Model Advisor when you select the check mathworks.maab.db_0140.

    specificInput = getInputParameterByName(cfgObj,"_SYSTEM_By Product_Simulink Check_Modeling Standards_JMAAB  v5.1 Checks_mathworks.maab.db_0140","Block type and parameters to check against defaults")
    

    The getInputParameterByName function returns the current value of the input parameter Block type and parameters to check against defaults of the check mathworks.maab.db_0140 in a structure array.

    ans = 
    
      struct with fields:
    
         name: 'Block type and parameters to check against defaults'
         type: 'BlockTypeWithParameter'
        value: [50×1 struct]

    Change a value in the value structure array:

    ans.value(1).name = 'Bool';

    Set the ans.value for Block type and parameters to check against defaults input parameter of the check mathworks.maab.db_0140 using jsonencode in the valueOfInputParameter input argument.

    setInputParameterbyName(cfgObj,"_SYSTEM_By Product_Simulink Check_Modeling Standards_JMAAB  v5.1 Checks_mathworks.maab.db_0140","Block type and parameters to check against defaults",jsonencode(ans.value))
    

    Input Arguments

    collapse all

    Model Advisor configuration object, specified as an Advisor.Config object.

    Instance ID of the check in Model Advisor, specified as a character vector or string scalar.

    The instance ID of the check represents the location of the check in the configuration file from which you want to get the input parameters.

    Example: '_SYSTEM_By Product_Simulink Check_Modeling Standards_JMAAB v5.1 Checks_mathworks.maab.db_0140'

    Name of the input parameter whose value is overwritten, specified as a character vector or string scalar.

    Example: 'Follow links'

    The value of an input parameter that overwrites the existing value, specified as a character vector or string scalar.

    Note

    If the input parameter is a structure array, then use jsonencode in the input argument. Refer Set Input Parameter with Value Struct of Model Advisor Check for more information.

    Example: 'on'

    Version History

    Introduced in R2025a