主要内容

运行选定模型顾问检查并生成报告

此示例说明如何以编程方式对 Simulink 模型运行选定模型顾问检查,检索各个检查的结果,并生成摘要显示检查结果的 HTML 报告。在此工作流中,此示例检查模型内未连接的信号线和单位不匹配情况,帮助识别潜在建模问题和复杂度。

打开示例模型:

model = "sldemo_mdladv";
open_system(model);

Create a Model Advisor object for the system:

ma = Simulink.ModelAdvisor.getModelAdvisor(model);
Updating Model Advisor cache...
Model Advisor cache updated. For new customizations, to update the cache, use the Advisor.Manager.refresh_customizations method.

Specify the Model Advisor checks to run by their IDs.

selectedCheck = {'mathworks.design.UnitMismatches','mathworks.design.UnconnectedLinesPorts'};

Run the Model Advisor checks.

a = runCheck(ma,selectedCheck);

Set the destination file for the report.

destination = fullfile(pwd,"AdvisorExport.html");

导出报告并捕获输出和消息。

[output,message] = exportReport(ma,destination);

显示结果。

if output
    fprintf("Report exported successfully: %s\n",message);
else
    fprintf("Report export failed: %s\n",message);
end
Report exported successfully: 

另请参阅

|

主题