Main Content

Run Selected Model Advisor Checks and Generate a Report

This example demonstrates how to programmatically run selected Model Advisor checks on a Simulink model, retrieve the results for individual checks, and generate an HTML report summarizing the findings. In this workflow, the example checks for unconnected lines and unit mismatch within the model, helping to identify potential modeling issues and complexity.

Open the example model:

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");

Export the report and capture the output and message.

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

Display the results.

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

See Also

|

Topics