Explore Model Hierarchy
Simulink® models can be organized into hierarchical components. In a hierarchical model, you can choose to view the system at a high level, or navigate down the model hierarchy to see increasing levels of model detail.
View Model Hierarchy
To start, open the smart_braking
model.
In the model:
A vehicle moves as the gas pedal is pressed.
A proximity sensor measures the distance between the vehicle and an obstacle.
An alert system generates an alarm based on that proximity.
The alarm automatically controls the brake to prevent a collision.
When you build a model, you connect blocks together to model complex components that represent system dynamics. In this model, Vehicle, Proximity sensor, and Alert system are all complex components with multiple blocks that exist in a hierarchy of subsystems. To view the contents of a subsystem, double-click the subsystem.
To view a representation of the complete model hierarchy, open the Model Browser.
Vertically expand the model window until the Hide/Show Model Browser button is visible in the lower left corner of the Simulink Editor.
Click the Hide/Show Model Browser button.
The Model Browser shows that all subsystems you view at the top level have subsystems of their own. Expand each subsystem node to see the subsystems it contains. You can navigate through the hierarchy in the Model Browser. For example, expand the Proximity sensor node and then select the Sensor model subsystem.
The address bar shows which subsystem you are viewing. To open the subsystem in a separate window, right-click the subsystem and select Open In New Window.
Every input or output port on a subsystem has a corresponding Inport or Outport block inside the subsystem. These blocks represent data transfer between a subsystem and its parent. When a system contains multiple input or output ports, the number on the Inport or Outport blocks indicates the position of the port on the subsystem interface.
View Signal Attributes
Signal lines in Simulink indicate data transfer from block to block. Signals have properties that correspond to their function in the model:
Dimensions — Scalar, vector, or matrix
Data type — String, double, unsigned integer, etc.
Sample time — A fixed time interval at which the signal has an updated value (or
0
for continuous sampling)
To show the data type of all signals in a model, in the Debug tab, under Information Overlays, click Base Data Types.
The model displays data types along the signal lines. Most signals are double, except
the output of the subsystem named Alert system
. Double-click the
subsystem to investigate.
The data type labels in this subsystem show that data type change occurs in the
subsystem named Alert device
. Double-click the subsystem to
investigate.
The alert device component converts the signal Alert index
from a
double to an integer. You can set the data type at sources, or use a Data Type
Conversion block from the Signal Attributes library. Double, the default data
type, provides the best numerical precision and is supported in all blocks. The double data
type also uses the most memory and computing power. Other numerical data types can be used
to model embedded systems where memory and computing power are limited.
To show sample times, in the Debug tab, under Information Overlays, click Colors from the Sample Time section. The model updates to show different colors for each sample time in the model, along with a legend.
A block or signal with continuous dynamics is black. Signals with continuous sample time update as often as the solver requires to satisfy specified tolerance values.
A block or signal that is constant is magenta. They remain unchanged through simulation.
A discrete block or signal that updates at the lowest fixed interval is red. Signals with discrete sample time update at a fixed interval. If the model contains components with different fixed sample times, each discrete sample time has a different color.
Multirate subsystems, which contain a mix of discrete and continuous signals, are yellow.
Trace a Signal
This model has a constant input and a discrete output. To determine where the sampling scheme changes, trace the output signal through its source blocks.
To open the Model Browser, vertically expand the model window until the Hide/Show Model Browser button is visible in the lower left corner of the Simulink Editor. Then, click the Hide/Show Model Browser button.
To start tracing the sources for the output signal, select the signal. Then, in the Signal tab, click Trace to Source .
The Simulink Editor enters signal tracing mode. In signal tracing mode, the model canvas becomes gray instead of white to help the traced path stand out.
The hints panel shows hints for actions you can take in signal tracing mode and the keyboard shortcut that corresponds to each action. To minimize the hints panel, press ? on your keyboard. If you want to restore the hints panel, press ? on your keyboard again.
To continue tracing the sources for the output signal, press the left arrow key.
Keep pressing the left arrow key to trace the sources for the output signal until you reach the Subtract block inside the subsystem named
Alert logic
. When you reach the Subtract block in the signal path, you must choose a path to continue tracing because the Subtract block has two input ports. The software highlights the next segment to trace in blue to indicate the selected path. By default, the first input port is selected for continued tracing. Select the path for the minus input port by pressing the down arrow key.To find the source of the discretization, continue pressing the left arrow and note the color of each port name, which reflects the sample time for the port.
The Zero-Order Hold block in the Sensor model subsystem coverts the signal from continuous to discrete.