As you gather requirements for a system, you can identify specific model components within the higher-level organization of inputs, outputs, and systems. To identify model components, the requirements and design can be only partially defined. For example, you might know where the interface among components will exist despite having an incomplete specification to describe that interface. To define model components without affecting simulation results and without investing time specifying an ambiguous interface, you can use Subsystem blocks to visually organize the model.
ex_modeling_components contains four common model components.
Mechanical System — a mass separated from a surface by a spring and damper
Controller — algorithm that controls the motion of the physical system
Operator — logic that defines the commands sent to the controller
Environment — external disturbances that affect the mechanical system
The ports on each of the Subsystem blocks correspond to input and output blocks within the subsystem. The block label shows the name of the corresponding port. For example, the Inport block labeled
disturbance corresponds with the
disturbance port of the mechanical system Subsystem block.
The four model components interact to determine the position of the mass.
The controller computes the force required to move the mechanical system to its goal position.
The operator determines the goal position of the mass and implements the related procedural logic with a Stateflow® chart.
The environment generates a disturbance force that affects the mechanical system.
During simulation, the operator tells the controller to wait 2 seconds, then move the mass up 2 meters. When the mass overshoots the goal position, the operator tells the controller to position the mass 1 meter above its original position. After 5 seconds, an environmental disturbance applies a steady force to the physical system and the controller reacts to stabilize the mass at the goal position.