Main Content

isConfigActive

Check if variant configuration is active

Since R2025a

    Description

    The function isConfigActive checks if the specified variant configuration is the active configuration for a model. You can use this function when defining variant constraints from Variant Manager. A constraint is a user defined check that you can use to prevent invalid variant combinations in a model. The constraint must be satisfied by all variant configurations created for the model. You specify constraints as condition expressions that must evaluate to true. The expression can contain variant control variables used by the model hierarchy as well as names of component configurations, which are variant configurations for referenced components present in the hierarchy. You can use the isConfigActive function to specify a component configuration name in the condition expression of a constraint, either from the Variant Manager user interface or by using the addConstraint function.

    For more information on component configurations, see Compose Variant Configurations and Constraints for Top Model Using Referenced Component Configurations.

    tf = isConfigActive(varconfigdata,nameofconfig) checks if the variant configuration nameofconfig is the active configuration for the model with which the Simulink.VariantConfigurationData object varconfigdata is associated. The function compares the values of variant control variables used in nameofconfig with their values in the data source where they are originally defined and returns a logical value 1 if the values match. nameofconfig must be defined in the object varconfigdata.

    example

    Examples

    collapse all

    Check whether a specified configuration is the active configuration for a model.

    Get the variant configuration data object for the model.

    open_system("slexVariantManagementExternalPlantMdlRef");
    subvcd = Simulink.VariantManager.getConfigurationData("slexVariantManagementExternalPlantMdlRef");
    

    Use the isConfigActive function to check if any of the named configurations in subvcd is active for the model.

    tf = isConfigActive(subvcd,"LowFid");
    tf = isConfigActive(subvcd,"HighFid");
    

    You can use the isConfigActive function to set up model-wide variant constraints using referenced component configurations.

    Add a constraint to the variant configuration data object vcd of the top-level model slexVariantManagement. Use the configurations in subvcd to define the condition for the constraint. Use the isConfigActive function call to specify the configuration names in the condition. The constraint defined here checks that configurations in vcd must have the control variable FidType defined in subvcd set to either Fidelity.Low or Fidelity.High.

    open_system("slexVariantManagement");
    vcd = Simulink.VariantManager.getConfigurationData("slexVariantManagement");
    addConstraint(vcd,"ExternalPantFidelityConstraint", ...
     "(isConfigActive(subvcd,""LowFid"") || isConfigActive(subvcd,""HighFid""))");
    

    Input Arguments

    collapse all

    Variant configuration data in which nameofconfig is defined, specified as a Simulink.VariantConfigurationData object.

    Name of the variant configuration to check, specified as a character vector or string scalar.

    Example: "LinInterExpNoNoise"

    Data Types: char | string

    Output Arguments

    collapse all

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

    Version History

    Introduced in R2025a