Convert a Subsystem to a Referenced Model

Determine Whether to Convert the Subsystem

Before you convert a subsystem to a referenced model:

(Optional) Update the Model Before Converting the Subsystem

    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.

  1. Set the Configuration Parameters > Diagnostics > Data Validity > Signal resolution parameter to Explicit only.

  2. Configure the following subsystem interfaces to the model.

    Subsystem InterfaceWhat to Look ForModel 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 stores

    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.

    Tunable parameters

    Global tunable parameters listed in the dialog box that opens when you click the Configuration Parameters > Optimization > Signals and Parameters > Configure button

    Use tunablevars2parameterobjects to create a Simulink.Parameter object for each tunable parameter.

    The Simulink.Parameter objects must have a storage class other than Auto.

    For more information, see Parameterize Model References and Tunable Parameters.

  3. Configure the subsystem and its contents.

    Subsystem ConfigurationWhat to Look ForModel 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.

    To have the new Model block behave similar to the subsystem variant, convert each variant subsystem separately and then use a Model Variants block. For more information, see Set Up Model Variants.

    Function calls

    Function-call signals that cross virtual subsystem boundaries.

    Move the Function-Call Generator block into the subsystem that you want to convert.

      Note:   If you convert an export-function subsystem, then you do not need to make this modification.

    Function-call outputs.

    Change the function-call outputs to data triggers.

    Wide function-call ports.

    Eliminate wide signals for function-call subsystems.

    Sample times

    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.

    Inport blocks

    Merged Inport blocks.

    Configure the model to avoid merged Inport blocks. See the Merge block documentation.

    Constant blocks

    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.

Run the Model Reference Conversion Advisor

Before you run the advisor, make sure that the model containing the subsystem that you want to convert compiles successfully.

  1. 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.

  2. Open the model and locate the subsystem to convert.

  3. 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.

  4. 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.

  5. Click Convert.

  6. Address any issues that advisor displays. For some issues, the advisor provides a Fix button to automatically address an issue.

  7. After you address the displayed issues, click Continue. Repeat steps 6 and 7 until no issues are flagged.

How to Revert the Conversion Results

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.

Integrate the Referenced Model into the Parent Model

  1. 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.

  2. 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.

  3. 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.

  4. 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

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:

  1. In the model workspace of the referenced model, create a variable for each masked parameter.

  2. 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.

  3. In the new Model block, for the Model arguments parameter, specify the values for the model arguments.

For masked callbacks, icons, ports, and documentation:

  1. In the backup copy, open the Mask Editor on the masked subsystem and copy the content you want into the masked Model block.

  2. In the Mask Editor for the new Model block, paste the masked subsystem content.

More About

Was this topic helpful?