Main Content

Diagnostic Viewer

View and diagnose errors and warnings generated by Simulink models

Description

Use the Diagnostic Viewer to view the diagnostic messages generated by a Simulink® model. A model generates diagnostic messages during various run-time operations, such as model load, simulation, build, or diagram update. The Diagnostic Viewer displays diagnostic messages as errors, warnings, or information.

The Diagnostic Viewer enables you to:

  • View diagnostic messages

  • Filter, search, save, copy, or group diagnostic messages

  • Fix errors and warnings by using suggested actions

  • Identify the sources of errors in a model

  • Suppress or restore diagnostic messages

  • Provide feedback to improve diagnostic messages

Toolbar

Manage diagnostic messages using the Diagnostic Viewer toolbar.

Toolbar ElementAction

Drop-down list of stages

The time and stages appear in a drop-down list. To view the diagnostic messages specific to a stage, select a stage from the drop-down list.

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

Click to filter all error messages. To remove the filter, click again.

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

Click to filter all warning messages. To remove the filter, click again.

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

Click to filter all information messages. To remove the filter, click again.

Text box to enter search string

Enter keywords to search specific messages.

Report menu

Save, copy, or clear all diagnostic messages using the Report menu.

To save or copy the messages for a selected stage, right-click anywhere inside the Diagnostic Viewer.

Settings menu

Group warnings with same message ID.

Diagnostic Message Pane

The diagnostic message pane displays the error, warning, and information messages for a selected stage. Each stage represents a run-time operation, such as model load, simulation, build, or diagram update. As more operations occur, new stages are created. For cases involving multiple operations, child stages are created to form a hierarchical structure.

These diagnostic messages are color-coded for quick identification:

  • a red and pink striped vertical bar — Errors

  • a yellow and orange striped vertical bar — Warnings

  • a red and yellow striped vertical bar — Errors encountered during model load. Any subsequent operations, such as model update without addressing these high priority warning messages, are marked as errors.

  • a light blue vertical bar — Information

When you point to a diagnostic message, you get the options to copy a diagnostic message or provide feedback. To copy a diagnostic message, click the copy icon . To provide feedback, click the add comment icon and enter your suggestions to improve the diagnostic message in the text box. The character limit of the feedback is 1024 characters.

Note

Use the feedback box to provide suggestions on diagnostic messages. To request help or report technical bugs, contact Technical Support at Contact Support.

Suggested Actions

For errors and warnings that have a predefined fix, Diagnostic Viewer also displays Suggested Actions. You can use these suggestions to fix the errors and warnings.

A diagnostic message can have multiple fixes and suggestions.

  • Fix — Use a suggested fix to automatically rectify the error. Each fix is associated with a Fix button. In some cases, you can also provide values before applying the fix.

    Once a fix is successfully applied, the Fix button for the diagnostic message is no longer available. If a fix was unsuccessful, the Diagnostic Viewer displays a failure message.

  • Suggestion — Use the suggestions for the errors and warnings that cannot be automatically fixed.

Diagnostic Viewer

Open the Diagnostic Viewer

In the Simulink toolstrip, select Debug > Diagnostics, and then select Diagnostic Viewer.

You can use the Diagnostic Viewer in two ways:

  • Standalone — Displays diagnostic messages of all the models in a separate window with one tab for each model.

  • Docked with model window — Displays the diagnostic messages specific to a model.

To dock the Diagnostic Viewer to a model, in the Debug tab of the toolstrip, select Diagnostics, and then select Docked Diagnostic Viewer. Alternatively, in the Modeling tab of the toolstrip, select Environment > Simulink Preferences. In the Simulink Preferences dialog box, select Editor > Use docked Diagnostic Viewer.

Note

Setting the Diagnostic Viewer as docked with model or standalone is a system-wide operation. The setting applies to all models.

Examples

expand all

You can use the Diagnostic Viewer to identify the sources of errors within a model.

When you simulate a model with an unconnected block, the Diagnostic Viewer displays a warning message. Click the hyperlink for the unconnected block in the warning message. The corresponding block in the model is highlighted for easy identification.

Model with the unconnected block highlighted in red and yellow

Use the Diagnostic Viewer to display the errors and warnings when you build a model using custom compilers. To achieve this, create a ToolchainInfo object for the selected compiler, and define compiler-specific patterns to identify and display the diagnostic messages on the Diagnostic Viewer.

To display diagnostic messages for a model using the MinGW64® compiler on a Linux® platform, use these steps.

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

Specify compiler-specific error and warning patterns.

tool.setDirective('ErrorPattern','error:');
tool.setDirective('WarningPattern','warning #(\d+):');

Specify compiler-specific filename and line number patterns.

tool.setDirective('FileNamePattern','[^\s]*\w+\.(c|h)');
tool.setDirective('LineNumberPattern','\(\d+\)');

The Diagnostic Viewer can trace the source 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 message shows 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 to 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

You cannot trace the exact source of an error or warning in a protected file.

Diagnostic Viewer allows you to suppress diagnostic messages for specific numerical errors and warnings, such as overflow, saturation, and precision loss for particular objects, and for errors where the diagnostic level is set to error in the Diagnostics section of the Model Configuration Parameters. When you suppress a diagnostic message, you can also add a justification for suppressing the message.

To suppress a diagnostic message, click Suppress. Any suppressions you apply to the diagnostic messages are saved with the model.

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

To add comments to the suppressed diagnostic message, click Add Justification. 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 messages of a model, open the Suppression Manager. On the Debug tab, select Diagnostics > Suppression Manager.

The Suppression Manager displays the diagnostic messages, suppression locations, and comments for a model in a tabular format. When you select a diagnostic message, you get the option to restore, add a comment, or move the diagnostic message to the parent level from the block level. Enter keywords in the Filter box to search the diagnostic messages, suppression locations, and comments. You can also select multiple diagnostic messages and leave a global comment.

Suppression Manager window

Alternatively, you can suppress the diagnostic messages programmatically as described in Suppress Diagnostic Messages Programmatically.

Version History

Introduced in R2014b