Create Model Components
As you gather requirements for a system, you identify model components. You can identify where component interfaces exist even with incomplete specifications.
To define model components without affecting simulation results and specifying an interface that may change, you can create subsystems and visually organize the model.
Some components, such as digital controllers, should execute as a single unit within the model. For these standalone components with known boundaries, you can use an atomic subsystem. Defining atomic components upfront prevents costly refactoring when you want to generate standalone code.
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 mechanical system
Operator — Logic that defines the commands sent to the controller
Environment — External disturbances that affect the mechanical system
The thicker line weight on the Controller block indicates that the controller is an atomic subsystem.
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 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.