Convert subsystem to model reference
= Simulink.SubSystem.convertToModelReference(subsys, mdlRef, 'opt1', 'val1',
... , 'optN', 'valN')
[success,mdlRefBlkH] = Simulink.SubSystem.convertToModelReference(subsys, mdlRef, 'opt1', 'val1', ... , 'optN', 'valN') converts a subsystem to a referenced model. The function creates a new model, copies the contents of the subsystem into the model, sets the model configuration parameters, and configures the model's root-level Inport and Outport blocks. By default, the function then replaces the subsystem block with a Model block that references the new model. Alternatively, you can set the input option ReplaceSubsystem to create another, temporary model containing a Model block that references the new model.
This function does not convert all kinds of subsystems to referenced models. For details, see Which Subsystems Can You Convert?.
Converting a subsystem to a referenced model requires your model to have the following configuration parameter settings:
Configuration Parameters > Diagnostics > Data Validity > Signal resolution is set to Explicit only.
Configuration Parameters > Diagnostics > Connectivity > Mux blocks used to create bus signals is set to Error.
You can use the following commands to set these parameters to the values required by this function:
set_param(mdlName, 'SignalResolutionControl', 'UseLocalSettings'); set_param(mdlName, 'StrictBusMsg', 'ErrorLevel1');
When the conversion is successful, you might need to reconfigure the resulting model to meet your requirements. For details, see Integrate the Referenced Model into the Parent Model.
Full name or handle of the subsystem to be converted
Name of the new model to convert the subsystem to
opt1, val1, ... , optN, valN
Zero or more pairs of options and values that control the conversion process. The options and values are:
The value is true if the conversion completed successfully, and false otherwise.
If you set the Force option to true, the success argument can be true, but it is possible that the converted model does not produce the same results as the model did before you converted the subsystem.
Handle of the Model block that references the new model.
If the top model uses a data dictionary that does not have any unsaved changes, Simulink uses the data dictionary to save the bus objects that it creates as part of the conversion processing.