Main Content

File Packaging for Models (Code and Data)

This example shows how referenced models provide system interface encapsulation and incremental code generation. You can reference one model from another model (one or more times), and aspects of the referenced model are fixed: input/output signal types, parameter types, and sample times. Therefore, you can modularize your design and perform incremental code generation.

The code generator partitions data and functions of a referenced model into its own set of files, independent of its parent model. In this example, the referenced model ReferenceModelCode is referenced three times. For simulation and code generation, the model is incrementally generated, which means ReferenceModelCode builds the first time, but not on subsequent builds, unless you change ReferenceModelCode.


  1. Generate and inspect the code.

  2. Change the value of one of the constant inputs in TopModelCode.

  3. Generate code. The code generator does not reproduce code for reference model TopModelCode.