Main Content

Display Port Values for Debugging

Display Port Values for Easy Debugging

For many blocks whose signals carry data, you can display signal values (block output values) in the block diagram using port value labels. Port value labels display block output values when the software runs block output methods. This model has a port value label displayed on the output port of a Constant block and a Math block. The port value labels show the block output values as 1 and 4.04.

If the port value label appears empty, no port value is currently available. For example, toggling a port value label on a continuous block when paused during simulation does not display any values in the label.

Port value labels are also empty when you have not yet simulated the model. This is because the block output methods do not run when the model does not simulate.

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

Displaying port value labels can help when you debug a model in the Simulink® Editor. For example, the image 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 by clicking Step Forward, 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. 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 enable and disable port value labels during simulation. Besides providing useful information for debugging, port value labels can help you monitor a signal value during simulation. However, port value labels are not saved with a model.

For nonnumeric data display, Simulink uses these values:

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 label might not be able to acquire the value signal

  • The signal value cannot be easily displayed

In such cases, the software uses these values.

MessageExplanation
...The signal dimension exceeds the maximum number of elements port value labels can display. For more information, see Display Port Values for a Model.
(no message)The simulation data available is insufficient. Step forward or click Run to obtain more data.
click to add signalsYou have enabled a port value label on a bus. However, you have not selected a signal to display. Click the label to select bus elements.
inaccessibleThe software cannot obtain the port value. For an example, see Signal Storage Reuse.
[m*n]This is a nonvector signal. The software cannot display the actual values of the matrix and displays the matrix dimension instead.
no data yet

This message appears when:

  • The simulation data is not available. Start the simulation to see values.

  • If the model contains subsystems (for example, an enabled subsystem) and model references and they are not executed during a simulation.

not usedThe software cannot obtain the signal value due to optimization.
removedThe software cannot obtain the signal value due to block reduction.
optimizedThe software cannot obtain the signal value due to optimization. In normal mode, this message appears for blocks with Conditional input branch execution enabled. For more information, see Conditionally Executed Subsystems Overview.
unavailableThe simulation data available is insufficient. For example, if you do not enable port value label when stepping forward, the data is not available when stepping back. When stepping back, if the port value is unavailable, the unavailable label is displayed.

Note

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

Display Value for a Specific Port

To display the value of a specific port or display port values for a block before simulation, select one or more signals, right-click the selection, and select Show Port Value Label on Selected Signal.

By default, the software displays the value of a signal when you click it during simulation. You can control this behavior. On the Debug tab, in the Tools section, select the Remove all port value labels button arrow , then select Options. In the Value Label Display Options dialog box, select Enable by default during simulation.

To remove all port value labels, on the Debug tab, in the Tools section, click Remove all port value labels .

For buses, the Show Value Label of Selected Port option opens a dialog box where you can select elements in the bus. For example, in this model, you can see the dialog box for all signals that in the bus ModelBus.

You can search for an element by name or filter through the hierarchy. Select a parent element to include all of the signals it contains. You can also filter the display to view only those signals you have selected.

Click anywhere outside the dialog box to close it. The port value label appears. The label has no data. The port value label updates to display the element values when you simulate the model.

When you simulate the model, the port value label shows the names and values of the signals you chose. To change the signals to display, open the dialog box again by clicking the port value label. You can also click another signal to display its value.

Note

The software does not retain signal values when you remove port value labels. If you add a port value label back immediately after removing it, the port value label displays no data yet.

Display Port Values for a Model

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

  1. In the model whose port values you want to display, on the Debug tab, select the Remove all port value labels button arrow , then select 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

Port Value Label 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

Port values work in normal and accelerator mode simulations only. They do not work in rapid accelerator or external mode simulations. 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 Display Port Values for Easy Debugging.

  • Model references simulated in accelerator mode do not get their port value labels updated.

Rapid AcceleratorNot supported. The limitation exists whether the model or its parent specifies accelerated simulation. For more information, see Accelerate, Refine, and Test Hybrid Dynamic System on Host Computer by Using RSim System Target File (Simulink Coder).

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 Signal storage reuse parameter. However, disabling signal storage reuse increases the memory used during simulation.

Signal Data Types

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

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

  • The software displays the port value of fixed-point data types based on the converted double value.

  • The software does not display data for signals with some composite data types, such as buses.

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, the software 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 label for a signal that goes into an Outport block displays the value of the Outport block, depending on the Output when disabled setting.

  • The software does not display data for the ports of an enabled subsystem that is not enabled.

Refine Factor

Port value labels do not reflect refine factor values (Configuration Parameters > Data Import/Export > Additional parameters > Refine factor) because the software updates port value labels 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, the software does not support port value labels in simulations started programmatically using the sim function.

Merge Block

The software does not display the input values to the Merge block. To see this value, refer to the source block.

Programmatic Interface

You cannot configure port value labels programmatically.

Non-Simulink signals

Port value labels are supported for only Simulink signals and are not supported for other types of signals, such as Simscape™ or SimEvents® signals.

Related Topics