Main Content

addReferencedConfiguration

R2026b

Associate top-model variant configuration with variant configuration of referenced model

Renamed from addComponentConfiguration in R2026b

    Description

    Consider a variant model that has predefined variant configurations and also has a referenced model in its model hierarchy. In Variant Manager, a variant configuration for a top-level model must also define the variant control variables used by any referenced components in the model hierarchy, such as referenced models. If the referenced component defines its own variant configurations, you can use them to set up the control variables in the top-level configuration.

    Use the addReferencedConfiguration function to associate a variant configuration of the referenced model with a variant configuration of the top-level model. This operation adds the control variables present in the specified referenced configuration to the top-level model configuration. This function thus allows you to author a top-model configuration using referenced configurations. For more information on this workflow, see Compose Variant Configurations and Constraints for Top Model Using Referenced Configurations.

    addReferencedConfiguration(vcoTop,ConfigurationName=topConfig,ReferencedComponentName=refMdl,ReferencedConfigurationName=refConfig) associates the variant configuration refConfig of the referenced model refMdl with the top-level variant configuration topConfig that is present in the variant configurations object vcoTop.

    This operation populates topConfig with variant control variables from refConfig. That is, topConfig contains all variant control variables that are in refConfig, these variables are set to the same values as in refConfig, and they are also marked as read-only in the top-level configuration. You cannot modify or remove the control variables populated using a referenced configuration from the top-model configuration. To populate variant control variables, refMdl is loaded. The operation also checks that there are no conflicts in existing variant control variable definitions of topConfig if it is associated with other referenced model configurations.

    example

    Examples

    collapse all

    Open the slexVariantManagement model.

    modelName = "slexVariantManagement";
    open_system(modelName);

    Get the variant configurations object associated with the model.

    vco = Simulink.VariantManager.getVariantConfigurations(modelName);

    The model has a referenced model named slexVariantManagementExternalPlantMdlRef in its hierarchy that has a predefined variant configuration named LowFid. This command associates LowFid with the variant configuration named NonLinExterLowFid present in vco and populates NonLinExterLowFid with the variant control variables from LowFid.

    addReferencedConfiguration(vco,ConfigurationName="NonLinExterLowFid", ...
        ReferencedComponentName="slexVariantManagementExternalPlantMdlRef",ReferencedConfigurationName="LowFid");

    Input Arguments

    collapse all

    Variant configurations object of the top-level model, specified as a Simulink.VariantConfigurations object.

    Name of the top-level variant configuration present in vcoTop to which the referenced component configuration refConfig is associated, specified as a character vector or string scalar.

    Example: "LinInterExpNoNoise"

    Data Types: char | string

    Name of the referenced component, such as a referenced model, specified as a character vector or string scalar.

    Example: "slexVariantManagementExternalPlantMdlRef"

    Data Types: char | string

    Name of the referenced component configuration to associate with the top-level configuration topConfig, specified as a character vector or string.

    Example: "HighFid"

    Data Types: char | string

    Version History

    Introduced in R2022b

    expand all