Main Content


Class: Simulink.VariantManager
Package: Simulink

Convert Subsystem, or Model block, or Variant Model block to a Variant Subsystem block


variant_subsystem = Simulink.VariantManager.convertToVariant(block)
variant_subsystem = Simulink.VariantManager.convertToVariant(blockHandle)


variant_subsystem = Simulink.VariantManager.convertToVariant(block) or variant_subsystem = Simulink.VariantManager.convertToVariant(blockHandle) converts a Subsystem, or Model block, or Variant Model block to a Variant Subsystem block. A Variant Subsystem can contain Subsystems, Model blocks, or both as choices.

Consider this model with Subsystem block.

You can convert this Subsystem block to a Variant Subsystem block using the convertToVariant method.

Similarly you can convert a Variant Model block to a Variant Subsystem block.

To convert a Variant Model block to a Variant Subsystem block, you can also 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

If there are inconsistencies in the port name or port number in models referenced by Variant Model block, Simulink® corrects these inconsistencies while converting the Variant Model block to Variant Subsystem block.

Consider this model with Variant Model block having different port names.

When you convert this Variant Model block to a Variant Subsystem block, the inconsistencies are corrected automatically.


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.


You cannot convert a Subsystem block that meets the following condition:

  • 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.

Input Arguments

expand all

The path or block handle of the Subsystem or Model block to convert to a Variant Subsystem block. Specify a block path as a character vector and a block handle as a scalar.

Output Arguments

expand all

If you specify an output argument, the method returns the block handle of the Variant Subsystem block created by the conversion.


   Simulink.VariantManager.convertToVariant('sldemo_mdlref_conversion/Bus Counter');

Alternative Functionality

Simulink Editor

In the Simulink Editor, right-click the Model block and select Subsystems & Model Reference > Convert to > Variant Subsystem.

Introduced in R2017b