Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Simulink.SubSystem.convertToModelReference - Convert atomic subsystem or function call subsystem to model reference

Syntax

[success,mdlRefBlkH] = Simulink.SubSystem.convertToModelReference(subsys, mdlRef, 'opt1', 'val1', ... , 'optN', 'valN')

Description

[success,mdlRefBlkH] = Simulink.SubSystem.convertToModelReference(subsys, mdlRef, 'opt1', 'val1', ... , 'optN', 'valN') converts an atomic subsystem or function call subsystem to a referenced model. The function creates a new model, copies the contents of the subsystem into the model, sets the new model's configuration parameters, and configures the model's root level Inport and Outport blocks. The function then replaces the subsystem block with a Model block that references the new model, or creates another, temporary model containing a Model block that references the new model, depending on the input option ReplaceSubsystem.

Converting a subsystem to a referenced model requires your model to have the following configuration parameter settings:

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');

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.

In the new model, the Interpolate data parameter of each root input port is selected by default. You can clear the parameter wherever this default is not appropriate. See the Inport block documentation for information about Interpolate data.

Inputs

subsys

Full name or handle of the atomic subsystem block to be converted

mdlRef

Name of the new model to which the subsystem is to be converted

opt1, val1, ... , optN, valN

Zero or more pairs of options and values that control the conversion process. The options and values are:

'ReplaceSubsystem'The option value is a Boolean. If the value is true, the function replaces the subsystem block with a Model block that references the model created from the subsystem. If this option is omitted or specified as false, the function creates and opens a model containing a Model block that references the model derived from the subsystem block. Default: false.
'BusSaveFormat'The option value can be 'Cell' or 'Object'. If the option is specified, the function saves any bus objects that it creates in an M-file. The value of the option specifies the format of the file. Use cell array format to save the objects in a compact form. If this option is omitted, the function does not save bus objects to a file.
'BuildTarget'The option value can be 'Sim' or 'RTW'. If the option is specified, the function generates a model reference Sim or RTW target for the new model, depending on the option value. If this option is omitted, the function does not generate a model reference target.
'Force'The option value is a Boolean. If the value is true, the function reports some errors that would halt the conversion process as warnings and continues with the conversion. This allows you to use the function to do the initial steps of conversion, and then complete the conversion process yourself. If this option is omitted or specified as false, the function halts the conversion if an error occurs. Default: false

Outputs

success

The value is true if the conversion completed successfully, and false otherwise.

mdlRefBlkH

Handle of the Model block that references the new model.

See Also

Converting a Subsystem to a Referenced Model | Simulink.BlockDiagram.copyContentsToSubSystem | Simulink.Bus.save | Simulink.SubSystem.copyContentsToBlockDiagram

Tutorials

How To

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS