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
More
Toolbar
Manage diagnostic messages using the Diagnostic Viewer toolbar.
Toolbar Element | Action |
---|---|
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. | |
Click to filter all error messages. To remove the filter, click again. | |
Click to filter all warning messages. To remove the filter, click again. | |
Click to filter all information messages. To remove the filter, click again. | |
Enter keywords to search specific messages. | |
Save, copy, or clear all diagnostic messages using the
To save or copy the messages for a selected stage, right-click anywhere inside the Diagnostic Viewer. | |
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:
— Errors
— Warnings
— Errors encountered during model load. Any subsequent operations, such as model update without addressing these high priority warning messages, are marked as errors.
— 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.
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
Identify Sources of Errors in a Model
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.
Display Diagnostic Messages from Custom Compilers
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+\)');
Trace Diagnostic Message Sources
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®.
Note
You cannot trace the exact source of an error or warning in a protected file.
Suppress Diagnostic Messages
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.
To add comments to the suppressed diagnostic message, click Add Justification. To restore the suppressed diagnostic, select 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.
Alternatively, you can suppress the diagnostic messages programmatically as described in Suppress Diagnostic Messages Programmatically.
Version History
Introduced in R2014b
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)