Main Content

Simulink.VariantManager.activateModel

Validate and activate variant blocks in model hierarchy

Since R2022b

Description

The Simulink.VariantManager.activateModel function allows you to validate and activate a variant configuration on the given model and any referenced components in the model hierarchy. You can activate a named variant configuration defined for the model or the workspace configuration (a temporary configuration based on current control variable values in the data sources used by the model).

The process checks if the variant elements in the model, such as variant blocks, variant controls, constraints, and the variant configuration, are set up correctly. When you activate a configuration using this function, it:

  • Checks if applicable constraints are satisfied

  • Pushes the variant control variables to the data sources where the variables are stored, for use in simulation and code generation workflows

  • Reports an error if the activation fails

Activation of a variant configuration performed by this function differs from the Simulink® update diagram process. See Differences Between Variant Manager Activation and Update Diagram Process.

Simulink.VariantManager.activateModel(modelName) validates and activates the workspace configuration on the model hierarchy. The variant control variables must be defined in the data sources used by the model.

example

Simulink.VariantManager.activateModel(modelName,Configuration=configName) validates and activates the specified named variant configuration on the model hierarchy.

You can use model compilation information when activating a variant configuration to produce more accurate activation results. See Simulink.VariantManager.updateModel.

Note

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

example

Examples

collapse all

This example shows how to validate and activate a variant configuration programmatically.

To activate a variant configuration from Variant Manager, see Create and Activate Variant Configurations.

Open the model slexVariantManagement.

open_system("slexVariantManagement");

Activate and validate the model using the variant control variables and their values currently stored in the data sources used by the model.

Simulink.VariantManager.activateModel("slexVariantManagement");

Activate and validate the model using the variant configuration LinInterExpNoNoise.

Simulink.VariantManager.activateModel ...
("slexVariantManagement",Configuration="LinInterExpNoNoise");

Input Arguments

collapse all

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

Example: "slexVariantManagement"

Data Types: char | string

Name of the variant configuration to be validated and activated, specified as a character vector or string.

Example: "LinInterExpNoNoise"

Data Types: char | string

Alternative Functionality

You can activate a variant configuration on a model using the Variant Manager user interface. For details, see Create and Activate Variant Configurations.

Version History

Introduced in R2022b

expand all