Main Content

Simulink.VariantManager.activateModel

Class: Simulink.VariantManager
Package: Simulink

Validate and activate variant blocks in model hierarchy

Description

Note

This method requires Variant Manager for Simulink®.

The Simulink.VariantManager.activateModel method 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 global workspace configuration.

The process validates 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 method, it:

  • Checks if applicable constraints are satisfied

  • Pushes the variant control variable values to the global workspace of the model, for use in simulation and code generation workflows

  • Reports an error if the activation fails

example

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

example

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

Note

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

Input Arguments

expand 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

Examples

expand all

This example shows how to validate and activate a variant configuration programmatically, using either the global workspace configuration or a named variant configuration.

Open the model slexVariantManagement.

open_system('slexVariantManagement');

Activate and validate the model using the global workspace configuration.

Simulink.VariantManager.activateModel('slexVariantManagement')

Activate and validate the model using the variant configuration, LinInterExpNoNoise.

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

Version History

Introduced in R2022b

expand all