Simulink.VariantUtils - Utility methods to work with variant elements - MATLAB (original) (raw)
Main Content
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.
Methods
Examples
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 to a Variant Subsystem block in expression
mode with control expression as V==1
, and the Variant activation time as update diagram
and Built-in empty choice turned on
.
open_system('f14'); Simulink.VariantUtils.convertToVariantSubsystem('f14/Controller', "VariantControlMode", ... 'expression', 'VariantControl', 'V==1', 'VariantActivationTime', 'update diagram', 'AllowZeroVariantControls', 'on', 'PassThrough', 'off');
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
The convertToVariant
,convertToVariantAssemblySubsystem
, and variantLegend
methods will be removed from the Simulink.VariantManager
class in a future release. The method calls continue to work with a warning.
Use the Simulink.VariantUtils
class to access these methods. TheconvertToVariant
method in the Simulink.VariantManager
class has been renamed to convertToVariantSubsystem
in theSimulink.VariantUtils
class.