| Simulink® | ![]() |
Convert atomic subsystem or function call subsystem to model reference
[success,mdlRefBlkH] = Simulink.SubSystem.convertToModelReference(subsys, mdlRef, 'opt1', 'val1', 'opt2', 'val2', ...)
[success,mdlRefBlkH] = Simulink.SubSystem.convertToModelReference(subsys, mdlRef, 'opt1', 'val1', 'opt2', 'val2', ...) converts an atomic subsystem or function call subsystem to a referenced model. The function does this by creating a new model, copying the contents of the subsystem into the model, and configuring the root level Inport and Outport blocks and configuration parameters of the new model. Then, based on its input arguments, the function either replaces the subsystem block with a Model block that references the new model, or it creates another, temporary model containing a Model block that references the new model.
Note Execute sldemo_mdlref_conversion at the MATLAB® command line for a demonstration of this command's usage. |
Converting a subsystem to a referenced model requires your model to have the following configuration parameter settings:
The Inline parameters option in the Optimization pane must be On.
The Signal resolution option in the Data Validity diagnostics pane must be set to Explicit only.
The Mux blocks used to create bus signals diagnostic in the Connectivity diagnostics pane must be set to Error.
You can use the following commands to set these parameters to the values required by this function:
set_param(mdlName, 'InlineParams', 'on'); set_param(mdlName, 'SignalResolutionControl', 'UseLocalSettings'); set_param(mdlName, 'StrictBusMsg', 'ErrorLevel1');
Note This function produces error or warning messages for models and subsystems that it cannot handle. Even if conversion is successful, you may still need to reconfigure the resulting model to meet your requirements. |
This function accepts the following arguments:
subsys — Full name or handle of the atomic subsystem block to be converted
mdlRef — Name of the model to which the subsystem is to be converted
'opt1', 'val1', 'opt2', 'val2'... — parameter/value pairs that specify various conversion options. This function support the following option pairs:
'ReplaceSubsystem', [true|{false}] — If the option value is true, this function replaces the subsystem block with a Model block that references the model created from the subsystem. If you do not specify this option or specify its value as false, this function creates and opens a model containing a Model block that references the model derived from the subsystem block.
'BusSaveFormat', ['Cell' | 'Object'] — If this option is specified, the function saves the bus objects that it creates in an M-file. See Simulink.Bus.save for more information.
'BuildTarget', ['Sim' | 'RTW'] — If you specify this option, this function generates a model reference Sim or RTW target for the new model.
'Force', [true|{false}] — If this parameter is true, this function reports some errors that would halt the conversion process as warnings and continues with the conversion. This allows you to use this function to do the initial steps of conversion and then complete the conversion process yourself. If you do not specify this option or specify it as false, this function halts the conversion if an error occurs.
This function returns the following outputs:
success — True if this function is successful; otherwise, false.
mdlRefBlkH — Handle of the Model block that references the new model
Simulink.BlockDiagram.copyContentsToSubSystem
Simulink.SubSystem.copyContentsToBlockDiagram
Converting a Subsystem to a Referenced Model
![]() | Simulink.Bus.save | Simulink.SubSystem.copyContentsToBlockDiagram | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |