Overview of Model Referencing

About Model Referencing

You can include one model in another by using Model blocks. Each instance of a Model block represents a reference to another model, called a referenced model or submodel. 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 referenced model's interface consists of its input and output ports (and trigger port in the case of a function-call model) and its parameter arguments. A Model block displays inputs and outputs corresponding to the root-level inputs and outputs of the model it references, enabling you to incorporate the referenced model into the block diagram of the parent model. For example, in the next figure the Model block in the parent model on the left could represent the submodel on the right:

You can use the ports on a Model block to connect the submodel to other elements of the parent model. Connecting a signal to a Model block port has the same effect as connecting the signal to the corresponding port in the submodel.

A referenced model can itself contain Model blocks and thus reference lower-level models, and so on to any depth. The topmost model in a hierarchy of referenced models is called the top model. Where only one level exists, the parent model and top model are the same. To prevent cyclic inheritance, a Model block cannot refer directly or indirectly to a model that is superior to it in the model reference hierarchy, as shown in this figure:

A parent model can contain multiple Model blocks that reference the same submodel as long as the submodel does not define global data. The submodel can also appear in other parent models at any level. You can parameterize a referenced model to provide tunability for all instances of the model, or let different Model blocks specify different values for variables that define the submodel's behavior. See Parameterizing Model References for details.

By default, the Simulink® software executes a top model interpretively, just as it would if the model did not include submodels. Simulink can execute a referenced model interpretively, as if it were an atomic subsystem, or by compiling the submodel to code and executing the code. See Referenced Model Simulation Modes for details.

You can use any referenced model as a standalone model, provided that it does not depend on any data that is available only from a higher-level model. An appropriately configured model can function as both a standalone model and as a referenced model without requiring any change to the model itself or to any entities derived from it.

Referenced Model Advantages

Like subsystems, referenced models allow you to organize large models hierarchically; Model blocks can represent major subsystems. Like libraries, referenced models allow you to use the same capability repeatedly without having to redefine it. However, referenced models provide several advantages that are unavailable with subsystems and/or library blocks:

Model Referencing Demos

Simulink includes several demos that illustrate model referencing. To access these demos from the MATLAB® command line:

  1. In the MATLAB Command Window, type

    demos

    A list of MATLAB products appears on the left side of the Help window.

  2. In the left side of the Help window, select Simulink.

    A list of Simulink demos appears on the right side of the Help window.

  3. Under Simulink, select Modeling Features.

    This category contains model referencing demos, including:

In addition, the demo sldemo_absbrake (Simulink > Automotive Applications > Modeling an Anti-Lock Brake System) represents a wheel speed calculation as a Model block within the context of an anti-lock braking system (ABS).

Model Referencing Resources

The following are the most commonly needed resources for working with model referencing:

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS