Simulink.VariantManager.convertToVariant
Class: Simulink.VariantManager
Package: Simulink
Convert Subsystem, Model, or Variant Model block to Variant Subsystem block
Description
Note
This method requires Variant Manager for Simulink®.
converts a Subsystem block, Model block, or
Variant Model block to a Variant Subsystem block. A
Variant Subsystem can contain Subsystem blocks,
Model blocks, or both as choices.variant_subsystem
= Simulink.VariantManager.convertToVariant(blockPathOrHandle
)
Note
Future releases will no longer support using a Model block to
contain model variants. You can use the convertToVariant
method
to convert model variants so that Model blocks are contained in a
Variant Subsystem. Use of a Variant Subsystem
block provides these advantages:
Allows you to mix Model and Subsystem blocks as variant choices
Supports flexible I/O, so that all variants do not need to have the same number of input and output ports
For an example of a model that uses a Variant Subsystem block as a container for variant models, see Model Reference Variants.
Input Arguments
Output Arguments
Examples
Limitations
The convertToVariant
method does not support these scenarios:
The Subsystem block is in a Simscape™ model that has Editing Mode set to Restricted.
The Variant Model block has a mix of control ports or there is a name mismatch in control port types.
The Variant Model block has control ports with different port numbers and name mapping.
Alternatives
Simulink Editor
In the Simulink Editor, right-click the Model block and select Subsystems & Model Reference > Convert to > Variant Subsystem.
Upgrade Advisor Check
To convert a Variant Model block to a Variant Subsystem block, you can use the Upgrade Advisor check Identify Variant Model blocks and convert those to Variant Subsystem containing Model block choices. This check provides a Fix button to convert Variant Model blocks to Variant Subsystem blocks. For more information on using Upgrade Advisor check to convert a Variant Model block to a Variant Subsystem block, see Upgrade Advisor Checks.
Version History
Introduced in R2017b