Main Content

Simulink.VariantManager.convertToVariantAssemblySubsystem

Class: Simulink.VariantManager
Package: Simulink

Convert Variant Subsystem block to Variant Assembly Subsystem block

Description

Note

This method requires Variant Manager for Simulink®.

example

Simulink.VariantManager.convertToVariantAssemblySubsystem(blockPathOrHandle) converts the Variant Subsystem block blockPathOrHandle to a Variant Assembly Subsystem block. Use this syntax if the Variant Subsystem block has only Model blocks and Subsystem Reference blocks as its variant choices.

example

Simulink.VariantManager.convertToVariantAssemblySubsystem(blockPathOrHandle,folderPathToKeepNewSubsystemFiles) converts the Variant Subsystem block blockPathOrHandle to a Variant Assembly Subsystem block. Use this syntax if the Variant Subsystem block has at least one Subsystem block as its variant choice. During the conversion, the Model and Subsystem Reference blocks, if any, continue to remain in the same location. The Subsystem blocks are converted to Subsystem Reference blocks and are saved in corresponding subsystem files inside the folder specified as folderPathToKeepNewSubsystemFiles.

Input Arguments

expand all

The path or the block handle of the Variant Subsystem block to convert to a Variant Assembly Subsystem block, specified as a character vector (for a block path) or double scalar (for a handle).

Example: 'slexVariantSubsystem/Controller'

Data Types: char | double

The relative or absolute path to the folder where all the new subsystem files must be created, specified as a character vector. The folder that you specify must be on the search path of your current MATLAB® session. For information on how to add files and folders to the MATLAB path, see addpath.

Example: 'ControllersList'

Data Types: char

Examples

expand all

This example explains how to convert the Variant Subsystem block in a Simulink® model to a Variant Assembly Subsystem using the Simulink.VariantManager.convertToVariantAssemblySubsystem method.

1. Consider the Controller block in the slexVariantSubsystems model. The Controller block is a Variant Subsystem block that is to be converted to a Variant Assembly Subsystem block.

modelName = 'slexVariantSubsystems';
open_system(modelName);
VSS_MODE = 2
vssBlockPath = [modelName, '/Controller'];

2. Set the variant control mode of the Controller block to label.

set_param(vssBlockPath, 'VariantControlMode', 'label');

3. To convert the Controller block to a Variant Assembly Subsystem block, use the convertToVariantAssemblySubsystem method. After the conversion, the Subsystem choices Linear_Controller and Nonlinear_Controller are converted to Subsystem Reference blocks with the same name as the Subsystem blocks. The Subsystem Reference blocks are saved in the newly created subsystem files Linear_Controller.slx and Nonlinear_Controller.slx in your current working folder.

Simulink.VariantManager.convertToVariantAssemblySubsystem(vssBlockPath, pwd);

Limitations

Only Variant Subsystem blocks with the Variant control mode set to label can be converted to a Variant Assembly Subsystem block.

Alternatives

You can convert a Variant Subsystem block to a Variant Assembly Subsystem block through the block dialog. For more information, see Convert Variant Subsystem to Variant Assembly Subsystem.

Version History

Introduced in R2022b