Documentation

Model Referencing

Reuse models as blocks in other models

You can include one model in another by using a Model block, which represents a reference to another model, called a referenced model. For simulation and code generation, the referenced model effectively replaces the Model block that references it. The model that contains a referenced model is its parent model. A collection of parent and referenced models constitutes a model reference hierarchy.

You can organize large models hierarchically, similar to using subsystems. Like libraries, referenced models allow you to use the same capability repeatedly without having to redefine it. Referenced models provide several advantages that are unavailable with subsystems and/or library blocks. Several of these advantages result from Simulink® compiling a referenced model independent of the context of the referenced model, including:

  • Modular development

  • Inclusion by reference

  • Incremental loading

  • Accelerated simulation

  • Incremental code generation

  • Independent configuration sets

To get started using model referencing, see Overview of Model Referencing.

Blocks

ModelInclude multiple model implementations as block in another model

Functions

find_mdlrefsFind Model blocks and referenced models at all levels or at top level only
view_mdlrefsDisplay graph of model reference dependencies
Simulink.SubSystem.convertToModelReferenceConvert subsystem to model reference
slbuildBuild standalone executable or model reference target for model; except where noted, this function requires a Simulink Coder license

Topics

Determine When to Use Model Referencing

Overview of Model Referencing

You can include one model in another by using Model blocks.

When to Use Model Referencing

Determine when to use model referencing to meet your modeling requirements.

Model Referencing Limitations

Model referencing has limitations relating to features such as simulation modes, masking, and debugging.

Set Up Model Referencing

Create a Referenced Model

Use a Model block to reference another model, using Inport and Outport blocks for the interface.

Convert a Subsystem to a Referenced Model

Use the Model Reference Conversion Advisor or Simulink.Subsystem.convertToModelReference function to convert subsystems to referenced models.

View Model Referencing Hierarchies

Examine a model reference hierarchy.

Define Referenced Model Inputs and Outputs

Specify the interface of inputs and outputs of referenced models, including the use of bus signals as inputs and outputs.

Refresh Model Blocks

To update the internal representation of a Model block so that it reflects changes in the interface of the model that it references, refresh the Model block.

Inherit Sample Times for Model Referencing

A referenced model can inherit sample times from the model that references it.

Set Configuration Parameters for Model Referencing

Configuration parameter values can be different in top models and referenced models. There are some configuration parameter values that have special requirements or behavior with model referencing.

Parameterize Instances of a Reusable Referenced Model

When you model a reusable component as a referenced model, to configure each instance of the component to use different values for block parameters, create model arguments.

Create and Reference Conditional Referenced Models

Execute referenced models conditionally, similarly to how you can execute conditional subsystems.

Use Masked Blocks in Referenced Models

Execute referenced models conditionally, similarly to how you can execute conditional subsystems.

Use S-Functions with Referenced Models

Use S-functions with model referencing.

Simulate Referenced Models

Simulate Model Reference Hierarchies

Select the simulation mode for simulating models in a model reference hierarchy.

Simulate Models with Multiple Referenced Model Instances

Simulate a model that contains multiple instances of a referenced model.

Model Reference Simulation Targets

A simulation target, or SIM target, is a MEX-file that implements a referenced model that executes in accelerator mode.

Reuse Simulation Builds for Faster Simulations

Use Simulink cache files to share referenced model build artifacts without repeating the cost of a first-time build.

Log Signals in Referenced Models

In a referenced model, you can log any signal configured for signal logging. You can override signal logging settings in referenced models.

Protected Models

Protected Model

Use a protected model to share a model without revealing its intellectual property.

Use Protected Model in Simulation

Use a protected model, which you can include in a protected model package.

Was this topic helpful?