This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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 and library files provide a single source for multiple instances of the same model component. You can reference a model to execute it as an independent unit within the parent model. You can also add linked blocks to your model that derive their contents from the source block in a library. To learn when you should use each of these componentization methods, see Component-Based Modeling Guidelines.

Model ex_modeling_component_reuse uses two linked blocks to represent identical mechanical subsystems.

When you navigate into a linked block, you see a read-only view of its contents.

Each of these linked blocks derives its content from a single block in library file ex_modeling_library.slx. To edit the contents, you must either disable the link to the source block or edit the contents directly in the source library.

In addition to using blocks linked to a library file, model ex_modeling_component_reuse references 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 script ex_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.

Related Topics