Contenu principal

setInputParameterByName

R2026b

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.

    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;

    Save the default Model Advisor configuration to a JSON file.

    saveConfiguration(cfgObj,"myCustomFile.json");

    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 the 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. To obtain the instance ID, right-click the check and click Copy.

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

    Verify the updated value by using getInputParameterByName.

    result = getInputParameterByName(cfgObj,"_SYSTEM_By Product_Simulink Check_Modeling Standards_JMAAB v5.1 Checks_mathworks.maab.db_0140","Follow links");
    result.value
    ans =
    
        'off'

    Update the value of a BlockType input parameter by passing a struct directly.

    Create a Model Advisor configuration object.

    cfgObj = Advisor.Config;

    Save the default Model Advisor configuration to a JSON file.

    saveConfiguration(cfgObj,"myCustomFile.json");

    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");

    Create a configuration that contains only the check mathworks.jmaab.jc_0008.

    createFromCheckList(cfgObj, {'mathworks.jmaab.jc_0008'});

    Refresh the Model Advisor customizations to apply the updated configuration.

    Advisor.Manager.refresh_customizations

    Specify the check instance ID and input parameter name. Create a struct that specifies the block types to check for output signal labels.

    instanceId = '_SYSTEM_mathworks.jmaab.jc_0008';
    paramName  = 'List of block types to check output signal labels';
    newValue   = struct('name', {'Inport', 'Gain'}, 'masktype', {'', ''});

    Update the List of block types to check output signal labels input parameter of the check.

    setInputParameterByName(cfgObj, instanceId, paramName, newValue);

    Verify the updated value by using getInputParameterByName.

    getInputParameterByName(cfgObj,instanceId,paramName)
    ans =
    
      struct with fields:
    
         name: 'List of block types to check output signal labels'
         type: 'BlockType'
        value: [2×1 struct]

    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, string scalar, or struct. For BlockType and BlockTypeWithParameter parameters, specify the value as a struct.

    Example: "on"

    Version History

    Introduced in R2025a