Main Content

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.

  1. Vertically expand the model window until the Hide/Show Model Browser button is visible in the lower left corner of the Simulink Editor.

  2. 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 top level view of the model smart_breaking has an annotation that indicates the data type on each signal line.

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 contents of the subsystem named Alert system show the signal data type annotations on the signal lines.

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 contents of the subsystem named Alert device contains a Data Type Conversion block. The signal data type annotations indicate the data type for the input and output signals of the Data Type Conversion block.

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.

Color coding in the top level view of the model smart_breaking indicates the sample time associated with each block, port, and signal line.

The Timing Legend groups sample times based on type and indicates the sample time that corresponds to each color in the block diagram.

  • 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.

  1. 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.

  2. 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.

    In the top level of the model smart_breaking, the output signal and the subsystem named Alert system, which produces the output signal, are highlighted yellow.

  3. To continue tracing the sources for the output signal, press the left arrow key.

    The Simulink Editor navigates inside the subsystem named Alert system to highlight the next source block that affects the value of the output signal.

  4. 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.

    Inside the subsystem named Alert logic, the signal path is highlighted in yellow up to the Subtract block. The signal connected to the minus input port of the Subtract block is highlighted blue.

  5. 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.

    Inside the subsystem named Sensor model, the Zero Order Hold block and the Outport block named proximity sensor output are highlighted.

The Zero-Order Hold block in the Sensor model subsystem coverts the signal from continuous to discrete.

Related Topics