Main Content

View Sample Time Information

Simulink® models can display color coding and annotations that represent specific sample times. You can display the blocks and signal lines in color. The annotations are badges on the output ports on the blocks and are colored in black:

  1. To enable colors, in the Simulink model window, on the Debug tab, select Information Overlays > Colors.

  2. To enable annotations, on the Debug tab, select Information Overlays > Text.

Selecting both Colors and Text displays both the colors and the annotations. Regardless of your choice, Simulink performs an Update Model automatically.

To turn off the colors and annotations:

  1. On the Debug tab, select Information Overlays > Colors to disable colors.

  2. On the Debug tab, select Information Overlays > Text to disable annotations.

When you change these settings, the software automatically performs Update Diagram.

Your sample time display choices directly control the information that the Timing Legend displays.

Note

The discrete sample times in the table Designations of Sample Time Information represent a special case. Three colors indicate the speed through the fifth fastest discrete rate. You can distinguish between these slower rates by looking at the annotations on their respective signal lines.

Inspect Sample Time Using Timing Legend

You can view the Timing Legend for an individual model or for multiple. To assist you with interpreting a block diagram, the Timing Legend contains the sample time color, annotation, and value for each sample time in the model. To view the legend:

  1. In the Simulink model window, on the Modeling tab, click Update Model.

  2. On the Debug tab, select Information Overlays > Legend, or press Ctrl+J.

    You can also use the shortcut on the Explorer Bar on the left side of the Simulink Editor.

In addition, when you select Colors or Text, the software updates the model diagram and opens the legend by default. The legend contents reflect your choices. If you turn colors on, the legend displays the color and the value of the sample time. If you turn annotations on, the annotations appear in the model.

The legend displays sample times present in the model, classified by the type of the sample time. To avoid clutter, the timing information is displayed in rows that expand to show more information about each specific sample time. You can expand each row to learn how that specific sample time is introduced in the model. Check boxes for sample times also allow you to choose specific sample times to display. The Timing Legend also displays the base rate and scalar multipliers for analysis of the discrete time-lines. Base rate in the variable step solvers is the greatest common divisor of all the discrete sample times in the model. The base rate is provided to help with the analysis of discrete sample times and their multiplier. The solver doesn't get affected by this base rate.

For discrete sample time, the Time/Freq toggle button allows you to choose the format of the multiplier information. All discrete sample times of the same color are combined into the same row, for example, periodic partitions, discrete export function etc. Triggered sample time rates are now visualized as their source sample times, illustrating the sample rate that drives the trigger. Annotations for aperiodic partition, reset, initialize, reinitialize, and terminate sample times do not use their event names as annotations but instead have their own concise annotations.

The animation that the sample time rows being expanded. It also shows the new colors of the Timing Legend, and how these new colors are used to color only the borders of the block.

The Timing Legend allows you to highlight the blocks and signals in the model that the sample time originates from. Expand a sample time row, and then click the hyperlink of the block, to see where the block is present in the model.

Note

The Timing Legend displays all of the sample times in the model, including those that are not associated with any block. For example, if the fixed step size is 0.1 and all of the blocks have a sample time of 0.2, then both rates (0.1 and 0.2) appear in the legend.

Starting in R2023b, you do not need to update the diagram for your model when changing the sample time visualization options or when launching the Timing Legend after model compilation.

If you do not want to view the legend upon selecting Sample Time Display:

  1. In the Simulink Editor, on the Modeling tab, select Environment > Simulink Preferences

  2. In the General pane, clear Open the timing legend when the sample time display is changed and click Apply.

Inspect Sample Times Throughout a Model

The Model Data Editor shows information about model data such as signals, parameters, and states, in a sortable, searchable table. To open the Model Data Editor, on the Modeling tab, click Model Data Editor.The Sample Time column shows the sample time specified for each signal in a model. After you update the block diagram, the column also shows the specific sample that each signal uses. For example, for signals for which you specify inherited sample time, the column shows -1. You can also use this column to specify sample times.

For more information, see Model Data Editor.

Related Topics