Main Content

configset.reference.isParameterOverridden

Determine if parameter is overridden in configuration reference of model

Since R2021a

    Description

    tf = configset.reference.isParameterOverridden(model, parameter) determines if the specified model uses a configuration reference in which the parameter that you specify is overridden. An overridden parameter can have a value that is different from the value in the referenced configuration set.

    example

    Examples

    collapse all

    Programmatically override a parameter in a configuration reference and set a value that is different from the referenced configuration set.

    Open the model slexConfigSetRefExample, which uses a configuration reference as the active configuration.

    model = 'slexConfigSetRefExample';
    open(model)

    Check if the model has any overridden parameters.

    configset.reference.hasOverriddenParameters(model)
    ans = logical
       0
    
    

    The model does not have any overridden parameters. For this example, override the parameter ModelReferenceMinAlgLoopOccurrences. This parameter attempts to eliminate artificial algebraic loops involving references to this model. In the referenced configuration set, the parameter is disabled. For the model slexConfigSetRefExample, enable the parameter by overriding it.

    configset.reference.overrideParameter(model,ModelReferenceMinAlgLoopOccurrences="on");

    Verify that the parameter ModelReferenceMinAlgLoopOccurrences is overridden and check its value for the model.

    configset.reference.isParameterOverridden(model,"ModelReferenceMinAlgLoopOccurrences")
    ans = logical
       1
    
    
    get_param(model,"ModelReferenceMinAlgLoopOccurrences")
    ans = 
    'on'
    

    Restore the parameter to the value in the referenced configuration set. Restoring the parameter makes it read-only again.

    configset.reference.restoreOverriddenParameter(model,"ModelReferenceMinAlgLoopOccurrences");

    If multiple parameters are overridden for the model, you can interact with all of them at once. For example, override the parameters StartTime, StopTime, and SolverType. Then, use the function configset.reference.getOverriddenParameters to see a list of the overridden parameters.

    configset.reference.overrideParameter(model,"StartTime");
    configset.reference.overrideParameter(model,"StopTime");
    configset.reference.overrideParameter(model,"SolverName");
    configset.reference.getOverriddenParameters(model)
    ans = 3x1 string
        "StartTime"
        "StopTime"
        "SolverName"
    
    

    Now, restore all of the overridden parameters for the model. The parameters reset to the values in the referenced configuration set and become read-only again.

    configset.reference.restoreAllOverriddenParameters(model)

    Input Arguments

    collapse all

    Model that uses configuration reference, specified as a character vector or string scalar.

    Example: 'mymodel'

    Parameter to check, specified as a character vector or string scalar.

    Example: 'ModelReferenceNumInstancesAllowed'

    Output Arguments

    collapse all

    True or false result, returned as a 1 or 0 of data type logical.

    Version History

    Introduced in R2021a