Main Content

Reuse Model Components from Files

When working on a large model, you can separate it into multiple files so that team members can develop different model components at the same time. You can reuse these components multiple times in a model and in other models.

Model, library, and subsystem files provide a single source for multiple instances of the same model component. To learn when you should use each of these componentization methods, seeComponent-Based Modeling Guidelines.

Subsystems

Modelex_modeling_component_reusereferences the contents of subsystem fileex_modeling_mechanical_system.slxtwice to represent identical mechanical subsystems.

While you can define a subsystem for reuse in either a library or subsystem file, subsystem files allow for easier editing. When you edit a referenced subsystem, the changes apply to the subsystem file and all instances of the referenced subsystem.

Models

Modelex_modeling_component_reusereferences the contents of model fileex_modeling_controller.slx. Controller code is often deployed on embedded systems, so having a standalone controller model is useful.

An embedded processor might not support default properties for the controller. Since a controller model might be used to generate code for an embedded processor, these constraints apply to the referenced controller model and the interface with its parent model:

  • Fixed Signal Attributes — To require that buses at model interfaces share the same signal attributes, bus objects specify signal attributes at the three sets of input and output ports.

  • Discrete Sample Time — To specify a discrete sample time, modelex_modeling_controllerspecifies a discrete execution domain and scriptex_modeling_data_controller.mspecifies discrete PID controller values.

  • Fixed Data Type — To apply the single-precision data type required by the embedded processor, Data Type Conversion blocks convert the bus element data types before they reach the model interface.

Related Topics