Convert subsystem to model reference
Simulink.SubSystem.convertToModelReference(gcb,'UseConversionAdvisor',true)
opens
the Model Reference Conversion Advisor for the currently selected
subsystem block.
[
converts
the specified subsystems to referenced models using the success
,mdlRefBlkHs
]
= Simulink.SubSystem.convertToModelReference(subsys
,mdlRefs
)mdlRefs
value.
For each subsystem that the function converts, it:
Creates a model
Copies the contents of the subsystem into the new model
Updates any root-level Inport, Outport, Trigger, and Enable blocks and the configuration parameters of the model to match the compiled attributes of the original subsystem
Copies the contents of the model workspace of the original model to the new model
Before you use the function, load the model containing the subsystem.
[
uses additional options specified by one or more
success
,mdlRefBlkHs
]
= Simulink.SubSystem.convertToModelReference(subsys
,mdlRefs
,Name,Value
)Name,Value
pair
arguments.
You cannot convert a parent subsystem and a child of that subsystem at the same time.
Specifying multiple subsystems to convert with one command can save time, compared to converting each subsystem separately. The multiple subsystem conversion process compiles the model once.
If you specify multiple subsystems to convert, the conversion process attempts to convert each subsystem. Successfully converted subsystems produce referenced models, even if the conversions of other subsystems fail.
If you specify multiple subsystems, consider:
In the input arguments, setting
'Autofix'
,
'ReplaceSubsystem'
, and
'CheckSimulationResults'
to
true
.
In the model, setting a short simulation time.
A data dictionary saves bus objects that it creates as part of the conversion process when both of these conditions exist:
The top model uses a data dictionary.
All changes to the top model are saved.
To maintain the behavior of a masked subsystem, perform these additional tasks:
For masked callbacks, icons, ports, and documentation, create a backup copy of the masked subsystem before converting it to a referenced model. After conversion, copy the content from the Mask Editor of the backup masked subsystem to the Mask Editor of the new Model block.
Replace mask parameters with model arguments (see Parameterize Instances of a Reusable Referenced Model).
Referenced models do not support the functionality that you can achieve with mask initialization code to create masked parameters.
Simulink.BlockDiagram.copyContentsToSubsystem
| Simulink.Bus.save
| Simulink.SubSystem.copyContentsToBlockDiagram