诊断
查看适用于模型的诊断、配置和自定义诊断检查、了解诊断查看器布局
在对模型执行 Simulink® 操作的过程中,如果检测到某些情况,Simulink 将会提供诊断消息。诊断消息分为错误、信息或警告三种类型。
在编程操作中遇到的诊断消息显示在 MATLAB® 命令行窗口中,而在 Simulink 用户界面操作中遇到的诊断消息显示在诊断查看器中。例如,如果使用 sim
函数从 MATLAB 命令提示符仿真模型,诊断消息将显示在命令行窗口中。但是,如果您从 Simulink 工具条中运行仿真,诊断消息将显示在诊断查看器中。
您可以自定义诊断消息,还可以自定义由软件检查的条件,以确定是产生错误还是警告。
适用于模型的诊断显示在诊断查看器用户界面上。有关诊断查看器的更多信息,请参阅诊断查看器。
还可以在模型中添加 Model Verification 模块,以检查特定信号的条件。有关模型验证的详细信息,请参阅运行模型顾问检查下列出的主题。
函数
类
Simulink.SuppressedDiagnostic | Suppress diagnostic messages from specific block |
sldiagviewer.DiagnosticReceiver | Create receiver to get diagnostic details of model operation (自 R2025a 起) |
命名空间
sldiagviewer | Summary of classes, functions, and namespaces associated with diagnostics |
sldiagviewer.Comparator | Summary of functions for comparing diagnostics (自 R2025a 起) |
App
参数量化顾问 | Inspect numerical issues related to parameter quantization (自 R2022b 起) |
工具
诊断查看器 | View, compare, and diagnose errors and warnings generated by Simulink models |
模型设置
检查
主题
诊断查看器
- 对错误和警告进行系统化诊断
系统化识别与定位错误和警告。 - 以编程方式报告诊断消息
使用sldiagviewer
函数生成、显示和记录诊断消息。 - Suppress Diagnostic Messages Programmatically
Suppress and restore diagnostic messages programmatically. - 自定义诊断消息
自定义错误消息以显示文本和超链接。 - Compare Diagnostic Messages Between Model Simulations
Compare diagnostic messages from different run-time operations of a model in the Diagnostic Viewer. - Compare Diagnostic Messages Between Model Simulations Programmatically
Compare diagnostic messages from different run-time operations of a model programmatically. - 使用 MSLException 对象处理 Simulink 中的错误
Simulink 允许您通过使用MSLException
对象(该对象基于 MATLABMException
对象)抛出异常来报告错误。与 MATLABMException
对象一样,您可以使用try-catch
模块和MSLException
对象来捕获有关错误的信息。MSLException
与MException
对象之间的主要区别在于MSLException
对象具有额外的 handles 属性。您可以通过这些句柄识别出与错误关联的对象。