Model hierarchy
Several blocks can be combined into a subsystem. This is necessary when the number of blocks in the model is so large that it becomes inconvenient to work with them.
Creating a subsystem
There are several ways to combine blocks into a subsystem:
-
Add a block Subsystem from the block library, double click on it with the left mouse button (this is how you enter the subsystem) and add the required blocks in the standard way.
-
Highlight the blocks you want to add to the subsystem with the Shift key pressed, click on the appearing dots in the corner of the rectangle and click on the
Subsystem icon.
Within one subsystem you can create an unlimited number of other subsystems at different levels of nesting. As a result, the model has a hierarchy. To navigate through different levels of the model use Navigation panel.
Using the Model block
To work with model hierarchies, in addition to subsystems, you can use the block Model.
Unlike a subsystem, the content of the Model block represents a separate model and can be reused in other models (several models can refer to the Model block).
Consequently, you can incorporate one model into another using a Model block. Each Model block is a reference to a particular model (submodel). Let’s consider an example:
To create a submodel, we use the blocks In1, Gain, Integrator and Out1. The parameters of the blocks remain by default.
In the future we plan to feed both input ports with the same signal, so we use the Duplicate function for Inport blocks:
Model view after input port conversion
The final submodel looks as follows:
Let’s save the submodel and give it a name, in our case - newmodel_12. In the future we will refer to this name in the parent model Model.
Next, let’s create a model from which we will refer to the submodel. We use the blocks Sine Wave Function, Model and Terminator.
For the Sine Wave block set the Sample time
value to 0.1
. The block will change. Then right-click on the Model block and select Parameters. This will open a settings window, inside which we will refer to the previously created newmodel_12 submodel:
The Model block will be modified to include input and output ports, to which we will connect the signal lines. For signals from the output ports we will set a record:
Let’s run the simulation of the model and see the graph. We leave the solver by default (Euler). The graph of sinusoidal signal simulation will be displayed in graph window :
|