Main Content

addComponentConfiguration

Class: Simulink.VariantConfigurationData
Namespace: Simulink

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

Since R2022b

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 addComponentConfiguration method 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 component configuration to the top-level model configuration. This method thus allows you to author a top-model configuration using referenced component configurations. For more information on this workflow, see Compose Variant Configurations for Top Model Using Referenced Model Configurations.

Note

This method requires Variant Manager for Simulink®.

example

addComponentConfiguration(vcdTop,ConfigurationName=topConfig,ComponentName=refmdl,ComponentConfigurationName=refConfig) associates the variant configuration refConfig of the referenced model refmdl with the top-level variant configuration topConfig that is present in the variant configuration data object vcdTop.

This operation populates variant control variables from refConfig to topConfig; 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 component 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

addComponentConfiguration(vcdTop,ConfigurationName=topConfig,ComponentName=refmdl,ComponentConfigurationName=refConfig,PopulateControlVariables=false) associates refConfig with topConfig but does not populate variant control variables from refConfig to topConfig and the variables are not marked as read-only. Use this syntax if you do not want to update existing control variable values in topConfig but only indicate that they come from refConfig. By default, PopulateControlVariables is set to true.

Input Arguments

expand all

Name of the variant configuration data object of the top-level model, specified as a character vector or string.

Example: "vcdo"

Data Types: char | string

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

Example: "LinInterExpNoNoise"

Data Types: char | string

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

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

Examples

expand all

Consider the slexVariantManagement model, which is associated with the variant configuration object vcd. 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 vcd and populates the variant control variables from LowFid to NonLinExterLowFid.

addComponentConfiguration(vcd,ConfigurationName="NonLinExterLowFid",...
    ComponentName="slexVariantManagementExternalPlantMdlRef",ComponentConfigurationName="LowFid");

This command associates LowFid with NonLinExterLowFid but does not update existing control variable values in NonLinExterLowFid.

addComponentConfiguration(vcd,ConfigurationName="NonLinExterLowFid",...
    ComponentName="slexVariantManagementExternalPlantMdlRef",...
    ComponentConfigurationName="LowFid",...
    PopulateControlVariables=false);

Version History

Introduced in R2022b

expand all