Main Content

View Diagnostics

You can view and diagnose errors and warnings generated by your model using the Diagnostic Viewer. The Diagnostic Viewer displays three types of diagnostic messages: errors, warnings, and information. A model generates these messages during a runtime operation, like model load, simulation, or update diagram.

You can dock the diagnostic viewer to a model to view diagnostics specific to the model or you can have a standalone diagnostic viewer to view the diagnostics of all the models.

To dock the diagnostic viewer to a model, go to Debug > Diagnostics > Docked Diagnostic Viewer or go to Modeling > Environment > Simulink Preference > Editor > Use docked Diagnostic Viewer.

Note

Docking the diagnostic viewer is a system-wide operation. You cannot change the preferences model-wise.

Simulink editor showing the block diagram of the model vdp_callback with a docked Diagnostic Viewer.

The diagnostic viewer window is divided into:

  • Toolbar menu: Displays various commands to help you manage the diagnostic messages. For more information, see Toolbar.

  • Diagnostic Message pane: Displays the error, warning, and information messages. For more information, see Diagnostic Message Pane.

  • Suggested Actions: Displays suggestions and fixes to correct the diagnostic errors and warnings. For more information, see Suggested Actions.

Toolbar

To manage the diagnostic messages, use the Diagnostic Viewer toolbar.

MenuAction

Exclamation mark in a solid red circle and a count of error messages

Filter all error messages. To remove filter, click again.

Exclamation mark in a solid yellow triangle and a count of warning messages

Filter all warning messages. To remove filter, click again.

Exclamation mark in a solid blue circle and a count of information messages

Filter all information messages. To remove filter, click again.

Text box to enter search string

Search messages for specific keywords and navigate between messages.

Drop-down list of stages

The time and events appear in this drop-down. You can view diagnostic messages specific to an event by clicking on the event.

Reports

You can

  • Expand or collapse messages

  • Save all or latest messages in a log file

  • Copy all or latest messages

Note

You can right-click anywhere inside the messages to save or copy the messages specific to the event.

Settings

Group similar warnings. Set maximum number of models to display in tabbed panes and the maximum number of events to display per model

Diagnostic Message Pane

The diagnostic message pane displays the error, warning, and information messages in a tabbed format. These messages are color-coded for distinction and are hierarchical.

A new stage is generated for each successive event, you can save or clear stage. Each stage represents a single event such as model load, update diagram, or simulation.

Different types of diagnostic messages are:

  • Information message: Displays the information related to a model load. Information messages are marked as a light blue vertical bar.

  • High priority warning: Displays the errors encountered during model load as a high priority warning. Any subsequent operation, like update on the model without rectifying the high priority warning messages are marked as errors. High priority warnings are marked as a red and yellow striped vertical bar.

  • Warning: Displays the warnings associated during an operation on a model. Warnings are marked as a yellow and orange striped vertical bar.

  • Error: Displays the errors associated during an operation on a model. Errors are marked as a red and pink striped vertical bar.

    Tip

    To locate the source of error, click the hyperlink in the message. The source of error in the model is highlighted.

    Block diagram of the model vdp_callback with the source of error highlighted red and yellow.

You can also provide feedback to improve a diagnostic message. To provide feedback, click Add Comment button next to the diagnostic message in the Diagnostic Viewer and enter your feedback in the text box. The character limit of the feedback is 1024 characters.

Note

To request help or report a technical bug, contact Technical Support at Contact Support.

Trace Diagnostics Location

The Diagnostic Viewer can trace the location of an error so that you can investigate the errors in your model easily. If the error is in a file that is being called from another file, the diagnostic shows up as an expandable stack. You can expand or collapse the stack, as required. Expanding the stack displays information about the file and the line in which the error or warning is located. You can click any of the links to go the error or warning. You can also see the same diagnostic message with stack trace enabled, while using the sim command in MATLAB®.

Diagnostic Viewer window displaying the diagnostic in an expanded stack.

Note

Tracing the exact location of an error is not applicable for protected files.

Identify Diagnostics from Custom Compilers

Diagnostic viewer can recognize errors and warnings from builds generated by custom compilers. You can specify compiler-specific patterns using the following directives:

% Here tool is the buildtool obtained from the toolchain
tool.setDirective ('WarningPattern','warning #(\d+):'); %Specifies warning patterns
tool.setDirective ('ErrorPattern','error:'); %Specifies error pattern
tool.setDirective ('FileNamePattern','[^\s]*\w+\.(c|h)'); %Specifies file name pattern
tool.setDirective ('LineNumberPattern','\(\d+\)'); %Specifies line number pattern

For more information about creating a ToolchainInfo object, see Register Custom Toolchain and Build Executable (Simulink Coder).

Suppress Diagnostics

You can suppress certain numerical diagnostics (for example, overflow, saturation, precision loss) for specific objects in your models from the Diagnostic Viewer. You can also suppress certain errors that have the diagnostic level set to error in the Diagnostics section of the Model Configuration Parameters. You can add a comment for the suppressed diagnostics.

To suppress a diagnostic from the specified source, click Suppress in the Diagnostic Viewer. Diagnostic suppressions are saved with the model and persist across sessions.

A warning message in Diagnostic Viewer with a button to suppress.

To add appropriate comments to the suppressed diagnostic, click Add Comment. To restore the suppressed diagnostic, select Restore.

Suppressed diagnostic in Diagnostic Viewer with hyperlinks to add a comment or restore.

To view the suppressed diagnostic, on the Debug tab, click Diagnostics > Suppression Manager.

The Suppression Manager displays the model name, suppression location, last modified details, and comments of the diagnostic in tabular format. Select the diagnostic to restore a diagnostic or move a diagnostic to the parent level from the block level (Add to Parent Level). You can add or edit inline comments against a diagnostic. Use the global Filter option to filter or search among the diagnostic messages, suppression location, and comments. You can also select multiple diagnostics and leave a global comment.

Suppression Manager window

For more information, see Suppress Diagnostic Messages Programmatically.

Suggested Actions

Diagnostic viewer provides suggestions and fixes for diagnostic error and warning messages. These suggestions and fixes are provided in the Suggested Actions section of diagnostic message pane.

A diagnostic error or warning can have multiple fixes and suggestions. Each fix is associated with a Fix button.

You can click the Fix button for the most suitable fix to rectify the error automatically. In some cases, you can provide the fix by one of these ways:

  • Enter the values in the available edit boxes.

  • Select a value from one of the listed values from a combo box.

Diagnostic Viewer window displaying a warning message and suggested actions with Fix and Apply buttons.

The Fix buttons for a diagnostic error or warning are no longer available after a fix is successfully applied. If a fix was unsuccessful, a failure message is displayed in the Suggested Actions section.

Suggestions are provided for errors and warnings that cannot be fixed automatically.

Diagnostic Viewer window displaying an error message and suggested actions.

Note

The Suggested Actions section is available only for the diagnostic errors or warnings that have a predefined fix.

Related Topics