|On this page…|
Before you convert a subsystem to a referenced model:
Tip Before you run the advisor, make sure that the model containing the subsystem that you want to convert compiles successfully.
You do not need to do anything else before running the advisor. The advisor automatically fixes or guides you through fixing the issues described in this section. However, if you are converting a large, complex subsystem, consider taking steps to prepare the model and subsystem to eliminate or reduce the number of issues that you need to address when you run the advisor. For a large, complex subsystem, it can be more efficient to address issues in the model editing environment than to switch repeatedly between the advisor and the Simulink® Editor.
Here are steps you can take to prepare your model before running the advisor.
Set the Configuration Parameters > Diagnostics > Data Validity > Signal resolution parameter to Explicit only.
Configure the following subsystem interfaces to the model.
|Subsystem Interface||What to Look For||Model Modification|
Goto or From blocks
Crossing of subsystem boundaries
Use an Inport block to replace From blocks that have a corresponding GoTo block that crosses the subsystem boundary.
Use an Outport block to replace each GoTo block that has corresponding From blocks that cross the subsystem boundary.
Connect the Inport and Outport blocks to the corresponding subsystem ports.
Data Store Memory blocks accessed by Data Store Read or Data Store Write blocks from outside of the subsystem
Replace the Data Store Memory block with a global data store. Define a global data store using a Simulink.Signal object. For details, see Data Stores with Signal Objects.
Global tunable parameters listed in the dialog box that opens when you click the Configuration Parameters > Optimization > Signals and Parameters > Configure button
The Simulink.Parameter objects must have a storage class other than Auto.
Configure the subsystem and its contents.
|Subsystem Configuration||What to Look For||Model Modification|
Inactive subsystem variants
Variant Subsystem blocks.
Make the subsystem variant that you want to convert active. The advisor does not convert inactive subsystem variants.
Function-call signals that cross virtual subsystem boundaries.
Move the Function-Call Generator block into the subsystem that you want to convert.
Change the function-call outputs to data triggers.
Wide function-call ports.
Eliminate wide signals for function-call subsystems.
Sample time of an Inport block that does not match the sample time of the block driving the Inport.
Insert Rate Transition blocks where appropriate.
Merged Inport blocks.
Configure the model to avoid merged Inport blocks. See the Merge block documentation.
Constant blocks that input to subsystems.
Consider moving the Constant blocks into the subsystem.
Bus signals that enter and exit a subsystem.
Match signal names and bus element names for blocks inside of the subsystem.
Consider using the Configuration Parameters > Diagnostics > Connectivity > Signal label mismatch diagnostic.
Duplicate signal names in buses.
Make signal names of the bus elements unique.
Signal names that are not valid MATLAB® identifiers. A valid identifier is a character string of letters, digits, and underscores, such that the first character is a letter, and the length of the string is less than or equal to the value returned by the namelengthmax function.
Change any invalid signal names to be valid MATLAB identifiers.
Note: As an alternative to running the Model Reference Conversion Advisor, you can use the Simulink.SubSystem.convertToModelReference function.
Before you run the advisor, make sure that the model containing the subsystem that you want to convert compiles successfully.
Save a backup copy of the model.
You can use the backup copy of the model to help to configure the model after performing the conversion. For example, if you convert a masked subsystem and want to mask the Model block, you can copy information from the masked subsystem into the masked Model block.
Open the model and locate the subsystem to convert.
Start the Model Reference Conversion Advisor.
In the Simulink Editor, right-click the subsystem that you want to convert. Select Subsystem & Model Reference > Convert Subsystem to > Referenced Model.
In the Model Reference Conversion Advisor dialog box, review the default settings for the Input Parameters. As appropriate, modify the parameters for running the advisor and click Apply.
Address any issues that advisor displays. For some issues, the advisor provides a Fix button to automatically address an issue.
After you address the displayed issues, click Continue. Repeat steps 6 and 7 until no issues are flagged.
If you are not satisfied with the conversion results and want to restore the model to the state it was in before you performed the conversion, select File > Load Restore Point.
In the Model Reference Conversion Advisor, if you cleared the > Replace subsystem with a Model block parameter before running the conversion checks, then in the source model, delete the Subsystem block and copy the new Model block where the subsystem was.
For root Inport blocks in the new referenced model, inspect the Interpolate data parameter to make sure it is appropriate. For details, see the Inport block documentation.
If you converted an active variant subsystem and want to achieve similar results in your model as you did by using the Variant Subsystem block, convert each of the variant subsystems to referenced models, and then use a Model Variants block. For more information, see Set Up Model Variants.
If you convert a masked subsystem, you might need to perform some additional tasks to maintain the same general behavior that the masked subsystem provided.
If you convert a masked subsystem, you may need to perform some additional tasks to maintain the same general behavior that the masked subsystem provided.
If the subsystem that you convert contains a masked block, consider masking the Model block in your new referenced model (see Masking). Configure the referenced model to support the functionality of the masked subsystem.
Note: A referenced model does not support the functionality that you can achieve with mask initialization code to create masked parameters.
For masked parameters:
In the model workspace of the referenced model, create a variable for each masked parameter.
In the Model Explorer, select the Model Workspace node. In the Dialog pane, in the Model arguments parameter, enter the variables that you want for model arguments.
In the new Model block, for the Model arguments parameter, specify the values for the model arguments.
For masked callbacks, icons, ports, and documentation:
In the backup copy, open the Mask Editor on the masked subsystem and copy the content you want into the masked Model block.
In the Mask Editor for the new Model block, paste the masked subsystem content.