Main Content

Simulink.VariantManager.applyConfiguration

Apply specified variant configuration to model

Since R2022b

Description

example

Simulink.VariantManager.applyConfiguration(model,Configuration=configName) applies the variant configuration specified by configName to the model model and any referenced components in the model hierarchy.

The variant configuration named configName must be present in the VariantConfigurationData object associated with model. The operation exports the variant control variables defined in the specified configuration to the base workspace or data dictionary used by the model.

This function allows you to quickly switch the variant configuration for a model. The function does not validate the configuration. To validate and activate a model using a specific configuration or using the currently applied configuration, use the Simulink.VariantManager.activateModel function.

Note

To use this function, you must install the Variant Manager for Simulink® support package.

Examples

collapse all

Open the model slexVariantManagement.

model = "slexVariantManagement";
open_system(model);

The model has multiple named variant configurations stored in the variant configuration data object vcd associated with the model.

You can compile or simulate the model for a configuration after applying the configuration to the model.

% Apply the configuration LinInterExpNoNoise
Simulink.VariantManager.applyConfiguration(model,Configuration="LinInterExpNoNoise");
% Compile the model
set_param(model,"SimulationCommand","update");
% Simulate the model
sim(model);

Input Arguments

collapse all

Name of the model to which the specified variant configuration must be applied, specified as a character vector or string.

Example: "slexVariantManagement"

Data Types: char | string

Name of the variant configuration that must be applied to the model, specified as a character vector or string.

Example: "Config1"

Data Types: char | string

Version History

Introduced in R2022b