This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Convert Subsystems to Referenced Models

Model reference offers benefits for modeling large, complex systems and for team-based development. Many large models use a combination of subsystems and referenced models. To decide whether to convert a subsystem to a referenced model, see Capabilities of Model Components and Guidelines for Component Size and Functionality.

The Model Reference Conversion Advisor does not support conversion for some types of subsystems.

Update Subsystem Block Contents for Conversion

The Model Reference Conversion Advisor helps you review and fix issues. Preparing the contents of a Subsystem block can eliminate or reduce the number of issues that the advisor identifies. Addressing these issues in the model editing environment can be more efficient than switching repeatedly between the advisor and the Simulink® Editor.

To convert the Subsystem block without preparing its contents, see Convert Subsystem Blocks to Model Blocks. Otherwise, take these steps to prepare Subsystem block contents:

  1. Set the Signal resolution parameter to Explicit only or None.

    You can use the Model Reference Conversion Advisor Fix option to address this issue.

  2. Configure the Subsystem block interface.

    Subsystem Block InterfaceWhat to Look ForModel Modification

    Goto or From blocks

    Goto or From blocks crossing the subsystem boundary

    Replace From blocks that have a corresponding Goto block that crosses the subsystem boundary with an Inport block.

    Replace each Goto block that has corresponding From blocks that cross the subsystem boundary with an Outport block.

    Connect the Inport and Outport blocks to the corresponding subsystem ports.

    You can use the Model Reference Conversion Advisor Fix option to address this issue.

    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.

    You can use the Model Reference Conversion Advisor Fix option to address this issue.

    Tunable parameters

    Global tunable parameters in the dialog box opened using the Configuration Parameters > Optimization > Configure button

    To create a Simulink.Parameter object for each tunable parameter, use tunablevars2parameterobjects.

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

    For more information, see Parameterize Instances of a Reusable Referenced Model and Tunable Parameters.

    You can use the Model Reference Conversion Advisor Fix option to address this issue.

  3. Configure the Subsystem block contents.

    Subsystem ConfigurationWhat to Look ForModel Modification

    Function calls

    Function-call signals that cross virtual subsystem boundaries

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


    If you convert an export-function subsystem, then you do not need to move the Function-Call Generator block.

    Function-call outputs

    Change the function-call outputs to data triggers.

    Wide function-call ports

    Eliminate wide signals for function-call subsystems.

    Sample times

    An Inport block sample time that does not match the sample time of the block driving the Inport block

    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 provide input for subsystems

    Move Constant blocks into the subsystem.


    Bus signals that enter and exit a subsystem

    Match signal names and bus element names for blocks inside the subsystem.

    To find signal names that do not match bus element names, use the Signal label mismatch diagnostic.

    Duplicate signal names in buses

    Make signal names of bus elements unique.

    Signal names that are not valid MATLAB® identifiers. A valid identifier is a character vector that meets these conditions:

    • The name contains letters, digits, or underscores.

    • The first character is a letter.

    • The length of the name is less than or equal to the value returned by the namelengthmax function.

    Change any invalid signal names to be valid MATLAB identifiers.

Convert Subsystem Blocks to Model Blocks

To convert a Subsystem block to a Model block, use the Model Reference Conversion Advisor.

  1. Make sure that the model containing the subsystem that you want to convert compiles successfully.

  2. For improved conversion performance, close any open Scope block windows.

  3. To open the Model Reference Conversion Advisor, right-click the Subsystem block and select Subsystem & Model Reference > Convert to > Referenced Model.

  4. Review the default settings under Input Parameters. Modify the parameters as needed, then click Apply.

    • The advisor can fix some conversion issues automatically. Select Fix errors automatically (if possible). This option can make the conversion process faster, but you do not control the fixes that the advisor makes.

    • The advisor can leave the Subsystem block in place and create a separate model from the contents of the Subsystem block. Clear Replace the content of a subsystem with a Model block.

    • The advisor can compare top-model simulation results before and after conversion. To compare simulation results:

      • Enable signal logging for output signals of interest

      • Select Check simulation results after conversion and Replace the content of a subsystem with a Model block

      • Set the Stop time, Absolute tolerance, and Relative tolerance

      • Set the Model block simulation mode option in the advisor to the same simulation mode as the original model

  5. Click Convert. For information about the checks, right-click the check (such as Check conversion input parameters) and select What's This?

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

  7. After you address each issue, click Continue until the advisor reports no remaining issues.

Alternatively, you can use the Simulink.SubSystem.convertToModelReference function. You can convert multiple Subsystem blocks using one Simulink.SubSystem.convertToModelReference command. However, you cannot convert a parent subsystem and a child of that subsystem at the same time.

Conversion Results

After the Model Reference Conversion Advisor runs all checks successfully, it:

  • Creates a referenced model from the subsystem.

  • Creates the bus objects, signal objects, and tunable parameters that the referenced model requires.

  • By default, replaces the Subsystem block with a Model block that contains the referenced model.

  • Inserts the Model block in a Subsystem block if the automatic fixes added ports to the Model block interface.

  • Creates an HTML conversion summary report in the slprj folder. This report summarizes the results of the conversion process, including the results of the fixes that the advisor performed. This report also describes the elements that it copies.

  • Optionally checks the consistency of simulation results before and after conversion.

The advisor copies the following elements from the original model to the new referenced model.

  • Configuration set — If the parent model uses:

    • A configuration set that is not a referenced configuration set, the advisor copies the entire configuration set to the referenced model

    • A referenced configuration set, then both the parent and referenced models use the same referenced configuration set

  • Variables — The advisor copies only the model workspace variables that the subsystem used in the original model to the model workspace of the referenced model. If the model that contained the subsystem uses a data dictionary, then the referenced model uses the same data dictionary.

  • Requirements links — The advisor copies requirements links created with Simulink Requirements™ software to the Model block from the original Subsystem block.

Compare Simulation Results Before and After Conversion

The Model Reference Conversion Advisor can compare simulation results before and after the conversion. After you successfully run the Complete conversion check, select Click here to view the comparison results. The results display in the Simulation Data Inspector. A green check mark indicates that simulation results are within tolerance between the baseline model and the model with the new referenced model.

For more information about the Simulation Data Inspector, see View and Analyze Simulation Results.

Revert the Conversion

If you are not satisfied with the conversion results, you can restore the model to its initial state. Use one of these approaches:

  • At any point during the conversion, select File > Load Restore Point.

  • After you successfully run the Complete conversion check, select Click here to restore the original model.

Integrate the Referenced Model into the Parent Model

After you complete the conversion, update the model as necessary to meet your modeling requirements. For example, you can manually replace a Subsystem block with a Model block that references the created referenced model.

If you want to simulate the model with external data, check that the root Inport blocks in the new referenced model have the appropriate Interpolate data parameter setting. See the documentation for the Interpolate data parameter of the Inport block.

See Also


Related Examples

More About