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, see Component-Based Modeling Guidelines.
Subsystems
Model ex_modeling_component_reuse
references the contents of subsystem file ex_modeling_mechanical_system.slx
twice 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
Model ex_modeling_component_reuse
references the contents of model file ex_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, model
ex_modeling_controller
specifies a discrete execution domain and scriptex_modeling_data_controller.m
specifies 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.