Display Port Values for Debugging

How Displaying Port Values Helps with Debugging

For many blocks whose signals carry data, Simulink® can display signal values (block output) as data tips (similar to tool tips) on the block diagram during and after a simulation. This model shows a data tip for the port on the Fcn block, an output value of –3.03.

Displaying port value data tips can help during interactive debugging of a model. For example, the figure shows the output of a thermal model for a house.

These results suggest a problem with the model because::

  • The heating cost is 0 at all temperatures.

  • The temperature inside the house matches ambient temperature almost exactly.

In such cases, debugging the blocks in the model interactively can help isolate the error. Port value labels provide information at the output of every block in the model. So in this example, if you step forward using Simulation Stepper, you can see that the output of the Heater subsystem is 0 at every time step.

To learn more, you can enable port value labels for blocks inside the Heater subsystem. Using Simulation Stepper, if you step forward again to display the values, you can see that there is an issue with the HeatGain block. The output is constant at 0.

This technique helps you isolate the issue.

To simplify debugging, you can turn on and off port value labels during simulation. Besides providing useful information for debugging, port value displays can help you monitor a signal value during simulation. However, these labels are not saved with a model.

For non-numeric data display, Simulink uses these strings:

MessageExplanation
actionThe signal executes action subsystems.
fcn-callThe signal is a function-call signal, e.g., Function Call Generator output.
groundThe signal is coming from a Ground block.
not a data signalThe signal does not contain valid data, e.g., the signal is from a block that is commented out.

In some cases:

  • The port value display may not be able to acquire the value signal or

  • The signal's value cannot be easily displayed

In such cases, Simulink uses these strings:

MessageExplanation
...The signal dimension exceeds the maximum number of elements Simulink can display. For more information, see Display Port Values for a Model.
(no message)The simulation data available is insufficient. Step forward or press play to obtain more data.
inaccessibleSimulink cannot obtain the port value. For an example, see Signal Storage Reuse.
[m*n]This is a nonvector signal. Simulink cannot display the actual values of the matrix. It displays the matrix dimension instead.
not usedSimulink cannot obtain the signal value due to optimization.
removedSimulink cannot obtain the signal value due to block reduction.
optimizedSimulink cannot obtain the signal value due to optimization.
unavailableThe simulation data available is insufficient. For example, see Simulation Stepper.

    Note:   You can force a value label to display the signal value by designating the signal as a test point. Use the Properties dialog box to do this.

Display Value for a Specific Port

  1. In the Simulink Editor model window, select the signal that is connected to the port whose value you want to display or the block whose port values you want to display.

  2. Select Display > Data Display in Simulation > Show Value Label of Selected Port.

    Note:   To remove the data tips, select Display > Data Display in Simulation > Remove All Value Labels.

Display Port Values for a Model

Specify port value display formatting and the frequency of updates. The Value Label Display Options dialog box controls these settings on the entire model.

  1. In the model whose port values you want to display, select Display > Data Display in Simulation > Options.

  2. In the Value Label Display Options dialog box, specify your preferences for:

    • The display options, including font size, the refresh frequency, and the number of elements displayed for vector signals with signal widths greater than 1

    • The display mode

    • Floating-point or fixed-point format

When No Data Is Available to Display

An empty box can appear when you toggle or hover on a block. This means that no port value is currently available. For example, toggling a port value label on a continuous block when paused during simulation can display an empty box. You also see the empty box if you have not yet simulated the model.

If you toggle or hover on a block that Simulink optimizes out of a simulation (such as a virtual subsystem block), the model displays the string optimized while you simulate.

Port Value Display Limitations

Performance

Enabling the hovering option for a model or setting at least one block to Toggle Value Labels When Clicked slows down simulation.

Accelerated Modes

The table shows how accelerator modes affect the display of port values.

Accelerated ModePort Values
Accelerator
  • Signals not optimized in Accelerator mode display port values as in Normal mode. Signals optimized in Accelerator mode display port values as optimized. For more information, see How Displaying Port Values Helps with Debugging.

  • Model reference blocks simulated in Accelerator mode do not get their port value displays updated.

Rapid AcceleratorIncompatible. The limitation exists whether the model or its parent specifies accelerated simulation. For more information, see Rapid Simulations.

Signal Storage Reuse

If the output port buffer of a block is shared with another block through the optimization of signal storage reuse, the port value displays as inaccessible. You can disable signal storage reuse using the Configuration Parameters > Optimization > Signals and Parameters > Signal storage reuse check box. However, disabling signal storage reuse increases the memory used during simulation.

Signal Data Types

  • Simulink displays the port value for ports connected to most kinds of signals, including signals with built-in data types (such as double, int32, or Boolean), DYNAMICALLY_TYPED, and several other data types.

  • Simulink shows the floating format for only noncomplex signal value displays.

  • Simulink displays the port value of fixed point data types based on the converted double value.

  • Simulink does not display data for signals with some composite data types, such as bus signals.

Inline Parameters

For models that use inline parameters (models that have Configuration Parameters > Optimization > Signals and Parameters > Inline parameters enabled), Simulink does not display port values for signals such as:

  • Constant input to an Enable block

  • Outputs of an Enable block that is never enabled

Subsystems

  • You cannot display port values for subsystems contained in a variant subsystem when there are no signal lines connecting to them. In such cases, during simulation, Simulink automatically determines block connectivity based on the active variant. However, you can display port values within the subsystems contained in the variant subsystem. You can also display values on signal lines outside of the variant subsystem.

  • When you disable a conditionally executed subsystem, the port value display for a signal that goes into an Outport block displays the value of the Outport block, depending on the Output when disabled setting.

Simulation Stepper

If you do not enable port value display when stepping forward, the display will not be available when stepping back. When stepping back, if the port value is unavailable, the unavailable label is displayed.

Refine Factor

Port value displays do not honor refine factor values (Configuration Parameters > Data Import/Export > Refine factor) because Simulink updates port value displays only during major time steps.

Signal Specification Block and Inport Block

When you display port values on Signal Specification and Inport blocks in a subsystem, the value that is driving the blocks displays instead of the block values.

Command-Line Simulations

For efficiency, Simulink does not support port value displays during a command-line simulation using the sim command.

Merge Block

Simulink does not display the output value of a merge block. To see this value, refer to the source block.

Command Line Interface

You cannot specify port value displays through the command line interface.

Non-Simulink signals

You cannot place port values on non-Simulink signals, such as Simscape™ or SimEvents® signals. This limitation applies to conditional breakpoints as well.

Was this topic helpful?