Main Content

convertDefaultToPreferred

Class: Simulink.VariantConfigurationData
Namespace: Simulink

Convert default variant configuration to preferred variant configuration

Since R2022b

Description

Setting a default variant configuration for a variant configuration data object is not recommended. If the variant configuration data object associated with your model has an existing default configuration, you can convert it to the preferred variant configuration using this method.

Note

This method requires Variant Manager for Simulink®.

vcdataObj.convertDefaultToPreferred() sets the existing DefaultConfiguration property of vcdataObj to its PreferredConfiguration property and then clears the DefaultConfiguration property. vcdataObj is an object of the Simulink.VariantConfigurationData class.

vcdataObj.convertDefaultToPreferred(model,Name=Value) sets the existing DefaultConfiguration property of vcdataObj to its PreferredConfiguration property and clears the DefaultConfiguration. It additionally updates the model callback functions specified using Name=Value arguments to activate the preferred variant configuration on the model.

The preferred variant configuration is not applied automatically when compiling or simulating a model. You must apply the preferred configuration explicitly on the model, if required. To additionally activate the preferred configuration on the model, you can set the Name=Value arguments in this method to add commands to the PostLoadFcn or InitFcn callbacks or both.

example

Input Arguments

expand all

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

Example: "slexVariantManagement"

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: AddActivateToPostLoadFcn = true

Option to add commands to the PostLoadFcn callback to activate the preferred configuration on the model, specified as a numeric or logical 1 (true) or 0 (false).

Example: true

Data Types: logical

Option to add commands to the InitFcn callback to activate the preferred configuration on the model, specified as a numeric or logical 1 (true) or 0 (false).

Example: true

Data Types: logical

Examples

expand all

Convert an existing default configuration of a variant configuration data object to its preferred configuration.

Convert the DefaultConfiguration of a variant configuration data object vcdataObj to its PreferredConfiguration and clear the DefaultConfiguration.

vcdataObj.convertDefaultToPreferred();

Convert the configuration and update the PostLoadFcn callback of the model to activate the preferred configuration:

vcdataObj.convertDefaultToPreferred(model, ...
AddActivateToPostLoadFcn = true);

Convert the configuration and update the InitFcn callback of the model to activate the preferred configuration:

vcdataObj.convertDefaultToPreferred(model, ...
AddActivateToInitFcn = true);

Convert the configuration and update both the PostLoadFcn and InitFcn callbacks of the model to activate the preferred configuration:

vcdataObj.convertDefaultToPreferred(model, ...
 AddActivateToPostLoadFcn = true,AddActivateToInitFcn = true);

Version History

Introduced in R2022b