mdlref_basic.mdl Open this Model

Basic Model Reference Demonstration

Introduction

This tutorial introduces some Model Reference concepts and demonstrates the feature's basic usage. It walks you through simulation and Real-Time Workshop code generation of a model that references another model multiple times.

Demo Requirements

If you haven't already opened it, open the demo model mdlref_basic. This model contains three Model blocks: CounterA, CounterB and CounterC. These blocks reference the same model mdlref_counter. The mdlref_counter model is a separate model and it is not a subsystem of mdlref_basic.

Model Reference has several advantages over subsystems:

Simulation Through Code Generation

Simulation of a model that references other models requires the generation of code and a binary file called the Simulation Target for each unique referenced model. For this demonstration, a simulation target is built for the mdlref_counter model. You can create the Simulation Target by any of the following actions:

Remarks:

Code Generation For Standalone Applications (Requires Real-Time Workshop)

When a standalone executable for mdlref_basic is created, first the code and binaries for the RTW Target of mdlref_counter are generated. The necessary RTW Targets are built if they are not up-to-date. You can build of the RTW target for mdlref_counter and the standalone executable for mdlref_basic by any of the following actions:

If you have not already built mdlref_basic, build mdlref_basic.

Remarks:

Incremental Loading Demonstration

  1. Close mdlref_counter and mdlref_basic and then reopen mdlref_basic.
  2. At the MATLAB prompt issue the command find_system('type','block_diagram'). The referenced model is not listed since it is not loaded.
  3. Double click on any Model blocks and press the Open Model button: CounterA, CounterB or CounterC.
  4. At the MATLAB prompt issue the command find_system('type','block_diagram') again. The referenced model is listed.

Exit

Close mdlref_counter and mdlref_basic.