This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Navigate Model

Simulink® models are hierarchical, so you can build models using both top-down and bottom-up approaches. You can view the system at a high level, then drill down to see increasing levels of model detail. This approach provides insight into how a model is organized and how parts interact.

To start, open the smart_braking model. In the MATLAB® Command Window, enter

open_system(fullfile(matlabroot,...
'help', 'toolbox', 'simulink', 'examples', 'smart_braking'))

This model includes the following components and data flow:

  • A vehicle moves as the gas pedal is pressed.

  • A proximity sensor measures its distance from an obstacle.

  • An alert system generates an alarm based on that proximity.

  • The alarm automatically controls the brake to avoid hitting the obstacle.

Navigate Through Model Hierarchy

You connect blocks together to model complex components. In this model, Vehicle, Proximity sensor, and Alert system are all complex components with multiple blocks, and they exist in a hierarchy of subsystems. To view its contents, double-click any subsystem:

To view the complete tree, click the Hide/Show Model Browser button at the bottom left corner of the model window.

The Model Browser shows that all subsystems you view at the top level also have subsystems of their own. Click > icons to see the subsystems. You can navigate through the hierarchy in the Model Browser. For example, click the Sensor model subsystem:

Observe that the subsystem is highlighted in the Model Browser. The address bar also shows which subsystem you are viewing. To open the subsystem in a separate window instead, right-click the subsystem name 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 indicate data transfer between a subsystem and its parent. In the case of multiple inputs or outputs, the number on the block designates which port it connects to on the subsystem.

View Signal Attributes

The signal lines in Simulink indicate data transfer from block to block. These signals have attributes essential to the function of the model:

  • Size: Scalar, vector, or matrix

  • Data type: String, double, unsigned integer, etc.

  • Sample time: The fixed time interval at which this signal has an updated value, or continuous sampling

To show the data type of all signals on a model, select Display > Signals & Ports > Port Data Types:

The model displays data types along the signal types. Observe that most signals are double, except the output of the Alert subsystem. Double-click this subsystem to investigate why:

The labels in this subsystem suggests that data type change occurs in the Alert device subsystem, double-click to investigate:

This shows that the Alert device component converts the alert index signal 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. The double data type, the default, provides the best numerical precision and is supported in all blocks. It also uses the most memory and computing power. Other numerical data types serve to model typical embedded systems where memory and computing power are limited.

To show sample times, select Display > Sample Time > Colors. This updates the model to show different colors for different sample times, and also displays a legend:

  • A block or signal with continuous dynamics is black. They update as often as Simulink requires to make the computations as close to the physical world as possible.

  • 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: They update only at fixed intervals. If the model contains components with different fixed sample times, each sample time has a different color.

  • A subsystem that contains continuous and discrete components are yellow: They are hybrid systems.

Trace a Signal

This model has a constant source and a discrete output. To determine where the sampling scheme changes., trace the output signal through blocks:

  1. Open the Model Browser: Click the Hide/Show Model Browser button .

  2. Highlight the source of the output signal: Right-click the signal and select Highlight Signal to Source.

    This takes the editor into highlight mode. Click the editor to continue. Make sure there is a blue frame around the editor.

  3. To continue tracing the signal to its source, press the left arrow key.

  4. Keep tracing the signal to its source until you reach the Alert logic subsystem. You see that the Subtract block has two inputs. Choose the signal path from the Inport by pressing the down arrow key.

  5. To find the source of the discretization, keep pressing the left arrow and note the colors of port names that reflect the sample time.

You find that the Zero-Order Hold block in the Sensor model subsystem does the conversion from continuous to discrete.