Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Consulting the Model Advisor

About the Model Advisor

The Model Advisor checks a model or subsystem for conditions and configuration settings that can result in inaccurate or inefficient simulation of the system that the model represents. If you have a Real-Time Workshop or Simulink® Verification and Validation™ license, the Model Advisor can also check for model settings that result in generation of inefficient code or code unsuitable for safety-critical applications. (For more information about using the Model Advisor in code generation applications, see Getting Advice About Optimizing Models for Code Generation in the Real-Time Workshop documentation.)

The Model Advisor produces a report that lists the suboptimal conditions or settings that it finds, suggesting better model configuration settings where appropriate. In some cases, the Model Advisor provides mechanisms for automatically fixing warnings and failures or fixing them in batches. For more information on individual checks, see Model Advisor Checks in the Simulink, Real-Time Workshop , and Simulink Verification and Validation Reference documentation.

Starting the Model Advisor

You can use any of the following methods to start the Model Advisor.

To start the Model Advisor... For a...Do this:
From the Model EditorModel or subsystem
  1. From the Tools menu, select Model Advisor.

    The System Selector window opens.

  2. Select the model or subsystem of interest.

  3. Click OK.

From the Model ExplorerModelIn the Contents pane, select Advice for model, where model is the name of the model that you want to check. (For more information, see The Model Explorer.)
From the context menuSubsystemRight-click the subsystem that you want to check and select Model Advisor.
ProgrammaticallyModel or subsystemAt the MATLAB prompt, enter modeladvisor(model), where model is a handle or name of the model or subsystem that you want to check. (For more information, see the modeladvisor function reference page.)

Overview of the Model Advisor Window

When you start the Model Advisor, the Model Advisor window displays two panes. The left pane lists the folders in the Model Advisor. Expanding the folders displays the available checks. The right pane provides instructions on how to view, enable, and disable checks, and provides a legend explaining the displayed symbols.

From the left pane, you can:

After running checks, the Model Advisor displays the results in the right pane. Additionally, the Model Advisor generates an HTML report of the check results, which you can optionally view in a separate browser window by clicking the Report link at the folder level.

To find checks and folders, enter text in Find and click the Find Next button ( ). The Model Advisor searches in check names, folder names, and analysis descriptions for the text.

Running Model Advisor Checks

To use the Model Advisor to perform checks on your model and view the check results:

  1. Open your model. For example, open the Model Advisor demo: sldemo_mdladv.

  2. Start the Model Advisor.

    1. From the Model Editor Tools menu, select Model Advisor .

      The System Selector window opens.

    2. In the System Selector window, select the model or system that you want to review. For example, sldemo_mdladv and click OK.

      The Model Advisor window opens and displays checks for the sldemo_mdladv demo model.

  3. In the left pane, expand the By Product folder to display the subfolders.

  4. In the left pane, expand the Simulink folder to display the available checks.

  5. Select the By Product folder in the left pane. The right pane changes to a By Product view.

  6. Select the Show report after run check box. This option causes an HTML report of check results to appear after you run the checks.

  7. Run the selected checks by clicking the Run Selected Checks button. After the Model Advisor runs the checks, an HTML report displays the check results in a browser window.

      Tip   While you can fix warnings and failures through Model Advisor reports, use the Model Advisor window for interactive fixing. Model Advisor reports are best for viewing a summary of checks.

  8. Return to the Model Advisor window, which shows the check results.

  9. Select an individual check to open a detailed view of the results in the right pane. For example, selecting Check optimization settings changes the right pane to the following view. Use this view to examine and exercise a check individually.

  10. After reviewing the check results, you can choose to fix warnings or failures as described in Fixing a Warning or Failure.

Fixing a Warning or Failure

Checks fail when a model or submodel has a suboptimal condition. A warning result is informational. You can choose to fix the reported issue, or move on to the next task. For more information on why a specific check does not pass, see the Simulink Checks documentation.

The Model Advisor provides the following ways to fix warnings and failures:

Manually Fixing Warnings or Failures

All checks have an Analysis Result box that describes the recommended actions to manually fix warnings or failures.

To manually fix warnings or failures within a task:

  1. Optionally, save a model and data restore point so you can undo the changes that you make. For more information, see Reverting Changes Using Restore Points.

  2. In the Analysis Result box, review the recommended actions. Use the information to make changes to your model.

  3. Rerun the check to verify that it passes.

      Caution   When you fix a warning or failure, rerun all checks to update the results of all checks. If you do not rerun all checks, the Model Advisor might report an invalid check result.

Automatically Fixing Warnings or Failures

Some checks have an Action box where you can automatically fix failures. The action box applies all of the recommended actions listed in the Analysis Result box.

To automatically fix all warnings or failures within a check:

  1. Optionally, save a model and data restore point so you can undo the changes that you made by clicking the Modify All button. For more information, see Reverting Changes Using Restore Points.

  2. In the Action box, click Modify All.

    The Action Result box displays a table of changes.

  3. Rerun the check to verify that it passes.

      Caution   When you fix a warning or failure, rerun all checks to update the results of all checks. If you do not rerun all checks, the Model Advisor might report an invalid check result.

Batch-Fixing Warnings or Failures

Some checks in the Model Advisor have an Explore Result button that starts the Model Advisor Result Explorer. The Model Advisor Result Explorer allows you to quickly locate, view, and change elements of a model.

The Model Advisor Result Explorer, a version of the Model Explorer, helps you to modify only the items that the Model Advisor is checking. For more information about using this window, see The Model Explorer.

If a check does not pass and you want to explore the results and make batch changes:

  1. Optionally, save a model and data restore point so you can undo any changes that you make. For more information, see Reverting Changes Using Restore Points.

  2. In the Analysis box, click Explore Result.

    The Model Advisor Result Explorer window opens.

  3. Use the Model Advisor Result Explorer to modify block parameters.

  4. In the Model Advisor window, rerun the check to verify that it passes.

      Caution   When you fix a warning or failure, rerun all checks to update the results of all checks. If you do not rerun all checks, the Model Advisor might report an invalid check result.

In the following example, run Check root model Inport block specifications for the sldemo_mdladv model. The result is a warning. Clicking the Explore Result button opens the Model Advisor Result Explorer window.

Reverting Changes Using Restore Points

The Model Advisor provides a model and data restore point capability for reverting changes that you made in response to advice from the Model Advisor. A restore point is a snapshot in time of the model, base workspace, and Model Advisor. The Model Advisor maintains restore points for the model or subsystem of interest through multiple sessions of MATLAB.

Saving a Restore Point

You can save a restore point and give it a name and optional description, or allow the Model Advisor to automatically name the restore point for you.

To save a restore point with a name and optional description:

  1. Go to File > Save Restore Point As.

    The Save Model and Data Restore Point dialog box opens.

  2. In the Name field, enter a name for the restore point.

  3. In the Description field, you can optionally add a description to help you identify the restore point.

  4. Click Save.

    The Model Advisor saves a restore point of the current model, base workspace, and Model Advisor status.

To quickly save a restore point, go to File > Save Restore Point. The Model Advisor saves a restore point with the name autosaven, where n is the sequential number of the restore point. If you use this method, you cannot change the name of, or add a description to, the restore point.

Loading a Restore Point

To load a restore point:

  1. Optionally, save a model and data restore point so you can undo any changes that you make.

  2. Go to File > Load Restore Point.

    The Load Model and Data Restore Point dialog box opens.

  3. Select the restore point that you want.

  4. Click Load.

    The Model Advisor issues a warning that the restoration will remove all changes that you made after saving the restore point.

  5. Click Load to load the restore point you selected.

    The Model Advisor reverts the model, base workspace, and Model Advisor status.

Viewing and Saving Model Advisor Reports

When the Model Advisor runs checks, it generates an HTML report of check results. Each folder in the Model Advisor contains a report for all of the checks in that folder and the subfolders within that folder.

Viewing Model Advisor Reports

You can access any report by selecting a folder and clicking the link in the Report box.

As you run checks, the Model Advisor updates the reports with the latest information for each check in the folder. A message appears in the report when you run the checks at different times. Time stamps indicate when checks have been run. The time of the current run appears at the top right of the report. Checks that occurred during previous runs have a time stamp following the check name.

You can manipulate the report to show only what you are interested in viewing as follows:

Saving Model Advisor Reports

You can archive a Model Advisor report by saving it to a new location. To save a report:

  1. In the Model Advisor window, navigate to the folder that contains the report you want to save.

  2. Select the folder that you want. The right pane of the Model Advisor window displays information about that folder, including a Report box.

  3. In the Report box, click Save As. A save as dialog box opens.

  4. In the save as dialog box, navigate to the location where you want to save the report, and click Save. The Model Advisor saves the report to the new location.

You can find the full path to the report in the title bar of the report window. Typically, the report is in the working directory: slprj/modeladvisor/model_name.

Running the Model Advisor Programmatically

You can create M-file programs that run the Model Advisor programmatically. For example, you can create an M-file program to check that your model passes a specified set of the Model Advisor checks every time you open the model or start a simulation or generate code from the model . For more information, see the Simulink.ModelAdvisor class.

The following M-file program is a simple example that selects and runs Check solver for code generation on the sldemo_mdladv model.

function result = demo_modelAdvisor_CommandLine
model = 'sldemo_mdladv';
load_system(model);

% Get model advisor handle
MdlAdvHandle = Simulink.ModelAdvisor.getModelAdvisor(model);

% BaselineMode false is for verification, true is for baseline
% generation
MdlAdvHandle.setBaselineMode(true);

% As an example, here we only select the check of choice 'Check solver for
% code generation'
MdlAdvHandle.deselectCheckAll;
MdlAdvHandle.selectCheck('Check solver for code generation');

% Run the selected check
MdlAdvHandle.runCheck;

% Get check result
result = MdlAdvHandle.getCheckResult('Check solver for code generation');
  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS