Main Content

Simulink.VariantUtils Class

Namespace: Simulink

Utility methods to work with variant elements

Since R2023b

Description

The Simulink.VariantUtils class provides a set of utility methods to work with variant blocks in Simulink®. With these methods you can:

  • Convert a Subsystem, Model, or Configurable Subsystem block to a Variant Subsystem block.

  • Convert a Variant Subsystem block to a Variant Assembly Subsystem block.

  • Display or change behavior of variant condition legend.

  • Update ports in a Variant Subsystem block to match its variant choices.

Class Attributes

Sealed
true

For information on class attributes, see Class Attributes.

Methods

expand all

Examples

collapse all

Convert the Subsystem block Controller in the f14 model to a Variant Subsystem block.

open_system('f14');
Simulink.VariantUtils.convertToVariantSubsystem('f14/Controller');

Convert the Subsystem block Controller in the f14 model model to a Variant Subsystem block in expression mode with control expression as V==1, and the variant activation time as update diagram and allow zero variant control turned on.

open_system('f14');
Simulink.VariantUtils.convertToVariantSubsystem('f14/Controller', "VariantControlMode", 'expression', 'VariantControl', 'V==1', 'VariantActivationTime', 'update diagram', 'AllowZeroVariantControls', 'on');

Convert the Model block CounterA in the sldemo_mdlref_basic model to a Variant Subsystem block.

open_system('sldemo_mdlref_basic');
Simulink.VariantUtils.convertToVariantSubsystem('sldemo_mdlref_basic/CounterA');

You can convert a Configurable Subsystem block to a Variant Subsystem block using the convertToVariantSubsystem method. See Convert Configurable Subsystem to Variant Subsystem.

Version History

Introduced in R2023b

expand all