Main Content

Model References

Reuse models as blocks in other models

A model reference is a reference to another model using a Model block. These references create model hierarchy. Each referenced model has a defined interface that specifies the properties of its inputs and outputs. The defined interface makes the behavior of the referenced model independent of its context in the model hierarchy. Model references are ideal for code reuse, unit testing, parallel builds, and large components. They can also reduce file contention and merge issues.

To determine whether referenced models meet your modeling requirements, see Component-Based Modeling Guidelines.

To learn about code generation for model reference hierarchies, see Referenced Models (Simulink Coder).

To create a protected model, see Model Protection (Simulink Coder).

To perform SIL/PIL testing for a model reference hierarchy, see SIL and PIL Simulations (Embedded Coder).


ModelReference another model to create model hierarchy
Variant ModelTemplate subsystem containing Subsystem, Model, or Subsystem Reference blocks as variant choices


expand all

depviewAnalyze and visualize model referencing dependencies with or without library dependencies
find_mdlrefsFind referenced models and Model blocks in model hierarchy
pathsToReferencedModelModel hierarchy path composed of referenced models and Model blocks (Since R2023b)
Simulink.BlockDiagram.refreshBlocksUpdate variants, linked blocks, and model references to reflect changes (Since R2023a)
Simulink.BlockPathFully specified Simulink block path
Simulink.fileGenControlSpecify root folders for files generated by diagram updates and model builds
Simulink.ModelReference.refreshForce update to Model block to reflect changes to referenced model (Since R2020a)
Simulink.SubSystem.convertToModelReferenceConvert subsystem to model reference
slbuildBuild standalone executable file or model reference target for model
slxcinfoQuery contents of Simulink cache files (Since R2020b)
slxcunpackUnpack simulation and code generation targets from Simulink cache file (Since R2020b)
Simulink.ProtectedModel.createHarnessCreate harness model that provides isolated environment for testing protected model (Since R2020b)
Simulink.ProtectedModel.getPublisherReturn information about publisher that signed the protected model (Since R2020a)
Simulink.ProtectedModel.verifySignatureVerify digital signature on protected model (Since R2020a)
Simulink.ProtectedModel.suppressSignatureVerificationSuppress digital signature verification of protected models (Since R2020b)

Model Settings

expand all

RebuildOption to conditionally, always, or never rebuild model reference targets
Never rebuild diagnosticDiagnostic action to take when model reference target must be rebuilt
Enable parallel model reference buildsOption to build a model reference hierarchy in parallel whenever possible
MATLAB worker initialization for buildsOptions for how to initialize MATLAB workers for parallel builds
Enable strict scheduling checks for referenced modelsOption to check consistency of scheduling and sample time in referenced models
Total number of instances allowed per top modelNumber of references to this model that can occur in another model
Propagate sizes of variable-size signalsOption to specify how variable-size signals propagate through referenced models
Minimize algebraic loop occurrencesOption to try to eliminate artificial algebraic loops related to referenced model
Propagate all signal labels out of the modelOption to pass propagated signal names out of referenced model
Use local solver when referencing modelOption to use local solver to solve referenced model as separate system of equations (Since R2022a)
Model dependenciesUser-created files and data that potentially impact simulation results
Perform consistency check on parallel poolOption to perform checks on parallel pool before starting parallel build (Since R2021a)
Include custom code for referenced modelsOption to use custom code in model reference simulation target
Pass fixed-size scalar root inputs by value for code generationOption to pass scalar input to model by reference or value
Model block version mismatchDiagnostic action to take when Model block does not represent current version of referenced model
Port and parameter mismatchDiagnostic action to take when port or parameter does not match between Model block and referenced model
Unsupported data loggingDiagnostic action to take when data logging is unsupported
No explicit final value for model argumentsDiagnostic action to take for model argument with default value at top-level model reference (Since R2020b)
Insufficient maximum identifier lengthDiagnostic action to take when maximum identifier length is too short to ensure unique global identifiers


Model Reference Conversion AdvisorConvert subsystems to referenced models
Referenced Files PaneView, save, and close referenced subsystems and models (Since R2020b)


Determine When to Reference Models

Create Model References

Configure Model References

Simulate Model Hierarchies