Documentation Center

  • Trials
  • Product Updates

Contents

Consult 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 Simulink® Coder™ 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 Advice About Optimizing Models for Code Generation in the Simulink Coder 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 Simulink Checks.

Software is inherently complex and may not be completely free of errors. Model Advisor checks might contain bugs. MathWorks® reports known bugs brought to its attention on its Bug Report system at http://www.mathworks.com/support/bugreports/. The bug reports are an integral part of the documentation for each release. Examine periodically all bug reports for a release as such reports may identify inconsistencies between the actual behavior of a release you are using and the behavior described in this documentation.

While applying Model Advisor checks to your model will increase the likelihood that your model does not violate certain modeling standards or guidelines, their application cannot guarantee that the system being developed will be safe or error-free. It is ultimately your responsibility to verify, using multiple methods, that the system being developed provides its intended functionality and does not include any unintended functionality.

Start the Model Advisor

There are two Model Advisor GUIs to run checks that verify the syntax of your model: the Model Advisor window and the Model Advisor dashboard.

If you want to ...Use the ... Set Preferences ...

Consistently run the same set of checks on your model.

Model Advisor dashboard. The Model Advisor dashboard does not reload checks for an analysis, saving analysis time.
  1. From the Model Editor, select Analysis > Model Advisor > Preferences.

  2. In the Model Advisor Preferences window, for the Default Mode, select Model Advisor Dashboard.

Select checks to run on your model.Model Advisor window.
  1. From the Model Editor, select Analysis > Model Advisor > Preferences.

  2. In the Model Advisor Preferences window, for the Default Mode, select Model Advisor.

Before starting the Model Advisor, make sure that the current folder is writable. If the folder is not writable, when you start the Model Advisor, you see an error message.

The Model Advisor uses the Simulink project (slprj) folder to store reports and other information. If this folder does not exist in the current folder, the Model Advisor creates it.

    Note:   If you Comment Blocks, they are excluded from both simulation and Model Advisor analysis.

To start the Model Advisor, use one of the following methods:

To open the Model Advisor window or Model Advisor dashboard ... For a...Do this action:
From the Model EditorModel or subsystem
  1. Select Analysis > Model Advisor > Model Advisor or Model Advisor Dashboard.

    Alternately, on the Model Editor toolbar drop-down list, select Model Advisor or Model Advisor Dashboard.

      Note:   Clicking opens the Model Advisor GUI set in the Analysis > Model Advisor > Preferences interface.

  2. In the System Selector window, select the model or subsystem that you want.

  3. Click OK.

From the Model ExplorerModelIn the Contents pane, select Advice for model. model is the name of the model that you want to check. (For more information, see Model Explorer Overview.)
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). 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. It also provides a legend describing the displayed symbols.

You can:

  • Select By Task to display checks related to specific tasks, such as updating the model to be compatible with the current Simulink version.

  • Select some or all of the checks using the check boxes or context menus for the checks, and then run one or all selected checks.

  • Reset the status of the checks to not run by right-clicking Model Advisor in the left pane and selecting Reset from the context menu.

  • Specify input parameters for some checks to run.

  • Select Code Generation Advisor to help configure your model to meet code generation objectives. See Application Objectives.

  • Select Upgrade Advisor to help upgrade and improve models with the current release. See Consult the Upgrade Advisor.

  • Select Performance Advisor to help improve the simulation performance of your model. See How Performance Advisor Improves Simulation Performance.

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

To customize the Model Advisor, on the toolbar, select Settings > Preferences to open the Model Advisor Preferences dialog box.

  • Show By Product Folder displays the checks available for each product.

  • Show By Task Folder displays checks related to specific tasks.

  • Show Source Tab displays the Source tab in the right pane of the Model Advisor window. When you click the Source tab, the Model Advisor window displays the check Title, TitleId, and location of the MATLAB source code for the check.

  • Show Exclusion tab displays the Exclusions tab in the right pane of the Model Advisor window. When you click the Exclusions tab, the Model Advisor window displays checks that are excluded from the Model Advisor analysis.

To run the selected checks, on the toolbar of the Model Advisor window, click Run selected checks ( ).

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. You can view this report in a separate browser window by clicking either Open Report ( ) or the Report link at the folder level.

To view the analysis results for individual checks, you can specify that the Model Advisor use color highlighting on the model diagram. To enable Model Advisor highlighting, do one of the following in the Model Advisor window, on the toolbar:

  • Select Highlighting > Enable Highlighting.

  • Click the Enable highlighting toggle button ( ).

When you use highlighting on the model diagram, you can specify that the Model Advisor highlight model blocks that are excluded from individual Model Advisor checks. On the toolbar of the Model Advisor window, select Highlighting > Highlight exclusions. If you have a Simulink Verification and Validation license, you can create or modify exclusions to the Model Advisor checks.

To switch to the Model Advisor dashboard, click the Switch to Model Advisor Dashboard toggle button ( ).

    Note   When you open the Model Advisor for a model that you have previously checked, the Model Advisor initially displays the check results generated the last time that you checked the model. If you recheck the model, the new results replace the previous results in the Model Advisor window.

Overview of the Model Advisor Dashboard

Using the Model Advisor dashboard, you can efficiently check that your model complies with modeling guidelines. When you use the Model Advisor dashboard, the Model Advisor does not reload checks for an analysis, saving analysis time.

To run checks, on the Model Advisor dashboard toolbar, click Run checks ( ).

After running checks, the Model Advisor generates an HTML report of the check results. You can view this report in a separate browser window by clicking the Open Report ( ).

To view highlighted results, click the Enable Highlighting toggle button ( ).

To switch to the Model Advisor window, click the Switch to standard view toggle button ( ).

    Tip   Use the Model Advisor window to select and view checks. To open the Model Advisor window, click the Switch to standard view toggle button ( ).

Run Model Advisor Checks

To perform checks on your model and view the results:

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

  2. Start the Model Advisor.

    1. From the Simulink Editor, select Analysis > Model Advisor > Model Advisor.

      Alternately, from the Simulink Editor toolbar drop-down list, select Model Advisor.

    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 model.

  3. In the left pane, expand the By Product or By Task folder to display the subfolders. Then expand the Simulink folder to display the available checks. If the By Product folder is not displayed in the Model Advisor window, select Show By Product Folder from the Settings > Preferences dialog box.

  4. In the left pane, select the By Product folder. The right pane changes to a By Product view.

  5. After you run the checks, select the Show report after run check box to see an HTML report of check results.

      Tip   Use the Model Advisor window for interactive fixing of warnings and failures. Model Advisor reports are best for viewing a summary of checks.

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

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

  8. Select an individual check to open a detailed view of the results in the right pane. For example, selecting Identify unconnected lines, input ports, and output ports changes the right pane to the following view. Use this view to examine and exercise a check individually.

  9. In the Model Advisor window, click the Enable highlighting toggle button ( ). Checks with highlighted results have an icon.

    • The model window opens. The blocks causing the Identify unconnected lines, input ports, and output ports check warning are highlighted in yellow.

    • The Model Advisor Highlighting information window opens with a link to the Model Advisor window. In the Model Advisor window, you can find more information about the check results and how to fix the warning condition.

  10. After reviewing these check results in the Model Advisor window, you can choose to fix warnings or failures as described in Fix a Warning or Failure.

Run Checks Using Model Advisor Dashboard

To run checks on your model using the Model Advisor dashboard:

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

  2. Start the Model Advisor dashboard.

    1. From the Simulink Editor, select Analysis > Model Advisor > Model Advisor Dashboard .

      Alternately, from the Simulink Editor toolbar drop-down list, select Model Advisor Dashboard.

    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 dashboard opens.

  3. Optionally, select or view checks to run on your model by clicking the Switch to standard view toggle button ( ). The Model Advisor window opens.

    1. For example, in the Model Advisor window, open the By Product folder and select checks:

      Identify unconnected lines, input ports, and output ports
      Check root model Inport block specifications

      If the By Product folder is not displayed in the Model Advisor window, select Show By Product Folder from the Settings > Preferences dialog box.

    2. Switch back to the Model Advisor dashboard by clicking the Switch to Model Advisor Dashboard toggle button ( ).

  4. On the Model Advisor dashboard, click Run checks ( ) to run the checks.

  5. Click the Enable Highlighting toggle button ( ) to view highlighted results.

    • The model window opens. The blocks causing the Identify unconnected lines, input ports, and output ports check warning are highlighted in yellow.

    • The Model Advisor Highlighting information window opens with a link to the Model Advisor window. In the Model Advisor window, you can find more information about the check results and how to fix the warning condition.

  6. After reviewing the check results, you can choose to fix warnings or failures as described in Fix a Warning or Failure. For example, fix the Identify unconnected lines, input ports, and output ports check warning:

    1. Connect model blocks Gain2 and Out4.

    2. On the Model Advisor dashboard, click Run checks ( ) to rerun the checks. The Model Advisor does not reload all the available checks, saving analysis time.

    The Identify unconnected lines, input ports, and output ports check passes.

Run Checks in the Background

If you have a Parallel Computing Toolbox™ license, you can run the Model Advisor in the background, allowing you to continue working on your model during Model Advisor analysis. When you start a Model Advisor analysis run in the background, Model Advisor takes a snapshot of your model. The Model Advisor analysis does not reflect changes you make to your model while Model Advisor is running in the background. To run a Model Advisor analysis in the background:

  1. Open your model.

  2. Start the Model Advisor.

    1. From the Simulink Editor, select Analysis > Model Advisor > Model Advisor.

    2. In the System Selector window, select the model or system that you want to review.

  3. In the Model Advisor window, click the Run checks in background toggle button ( ).

  4. In the left pane of the Model Advisor window, select the checks that you want to run.

  5. Run the selected checks in the background. In the Model Advisor window, select Run selected checks ( ).

    Alternately, you can use the Model Advisor dashboard to run the checks. In the Model Advisor window, switch to the Model Advisor dashboard by clicking the Switch to Model Advisor Dashboard toggle button ( ). On the Model Advisor dashboard, click Run selected checks ( ).

    The Model Advisor launches an analysis on a parallel processor.

  6. To stop running checks in the background, in the Model Advisor window, click Stop background run ( ). In the Model Advisor window, in the lower-left pane, you see a status of the analysis.

  7. Once the Model Advisor analysis is complete, you can address the check results. See Highlight Model Advisor Analysis Results, Fix a Warning or Failure, and View and Save Model Advisor Reports.

    The Explore Result option is not available for checks that are run in the background.

Highlight Model Advisor Analysis Results

You can use color highlighting on the model diagram to indicate the analysis results for individual Model Advisor checks. Blocks that pass a check, fail a check, or cause a check warning are highlighted in color in the model window. Model Advisor highlighting is available for the following:

  • Simulink blocks

  • Stateflow® charts

After you run a Model Advisor analysis, checks with highlighted results are indicated with an icon in the Model Advisor window.

To use Model Advisor highlighting:

  1. Run Model Advisor checks on your model.

  2. Enable Model Advisor highlighting by doing one of the following:

    • On the toolbar of the Model Advisor window, select Highlighting > Enable Highlighting.

    • On the toolbar of the Model Advisor window, click the Enable highlighting button ( ).

    • On the toolbar of the Model Advisor Dashboard, click the Enable Highlighting button ( ).

  3. Optionally, to view model blocks that are excluded from the Model Advisor checks, select Highlighting > Highlight Exclusions on the Model Advisor window toolbar. If you have a Simulink Verification and Validation license, you can create or modify exclusions to the Model Advisor checks .

  4. In the left pane of the Model Advisor window, select a check with highlighted results. Checks with highlighted results are indicated with the icon. Highlighting is not available for some checks.

    Both the model window and a Model Advisor Highlighting information window open. The Model Advisor Highlighting information window provides a link to the Model Advisor window, where you can review the check results.

    Highlight Colors in the model window

    Yellow with orange border

    Blocks that cause the check failure or warning.

    White with orange border

    Subsystem with blocks that cause the check warning or failure.

    White with gray border

    Blocks or subsystems without highlighting.

    Gray with black border

    Blocks that are excluded from the check.

    White with black border

    Subsystems that are excluded from the check.

  5. After reviewing the check results in both the model window and the Model Advisor window, you can choose to fix warnings or failures as described in Fix a Warning or Failure.

  6. To view highlighted results for another check, in the left pane of the Model Advisor window, select a check with an icon.

    Tip   If a check warns or fails and the model window highlights blocks in gray, closely examine the results in the Model Advisor window. A Model Advisor check might fail or warn due to your parameter or diagnostic settings.

Fix a Warning or Failure

Checks fail when a model or referenced model 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 check documentation. You can use Model Advisor highlighting to identify model objects that cause a check warning or failure.

    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.

To fix warnings and failures:

Manually Fix Warnings or Failures

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 Revert Changes.

  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 Fix 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.

    Caution   Before automatically fixing failures, review the Analysis Result box to verify that you want to apply all of the recommended actions. If you do not want to apply all of the recommended actions, do not use this method to fix warnings or failures.

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 Revert Changes.

  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-Fix 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 helps you to modify only the items that the Model Advisor is checking.

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 changes that you make. For more information, see Revert Changes.

  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.

Revert Changes

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. You can also restore the default configuration of 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.

    Caution   A restore point saves only the current working model, base workspace variables, and Model Advisor tree. It does not save other items, such as libraries and referenced models.

Restore Default Configuration

To restore the default configuration, in the Model Advisor window, select Settings > Restore Default Configuration.

Save 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:

  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. 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.

Load a Restore Point

To load a restore point:

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

  2. Select File > Load Restore Point.

  3. In the Load Model and Data Restore Point dialog box, select the restore point that you want.

  4. Click Load.

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

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

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

View and Save 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 the checks in that folder and the subfolders within that folder.

View Model Advisor Reports

You can access a report by selecting a folder and clicking the link in the Report box. Alternately, before a Model Advisor analysis, in the right pane of the Model Advisor window, select Show report after run.

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

As you run checks, the Model Advisor updates the reports with the latest information for each check in the folder. When you run the checks at different times, an informational message appears in the report. 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.

To display only what you are interested in viewing, use the left pane of the report.

  • To display results for checks that pass, warn, or fail, use the Filter checks check boxes. For example, to display only results for checks that warn, in the left pane of the report, select the check box next to Warning. Clear the check boxes next to Passed, Failed, and Not Run.

  • To display results for checks with keywords or phrases in the check title, use the Keywords field. Results for checks without the keyword in the check title are not displayed in the report. For example, to display only results for checks with ‘setting' in the check title, in the Keywords field, enter ‘setting'.

  • To quickly navigate to sections of the report, select the links provided in the table-of-contents navigation pane.

  • To expand and collapse content in the check results, click Show/Hide check details.

  • To scroll to the top of the report, click Scroll to top.

  • To minimize folder results in the report, click the minus sign next to the folder name.

Printed versions of the report do not contain the:

  • Filtering checks, Navigation, or View panes.

  • Content hidden due to filtering or keyword searching.

Some checks have input parameters specified in the right pane of the Model Advisor. For example, Check Merge block usage has an input parameter for Maximum analysis time (seconds). When you run checks with input parameters, the Model Advisor displays the values of the input parameters in the HTML report.

For more information, see the EmitInputParametersToReport property of the Simulink.ModelAdvisor class.

Save Model Advisor Reports

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

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

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

  3. In the Report box, click Save As.

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

    Note:   If you rerun the Model Advisor, the report is updated in the working folder, not in the save location.

The full path to the report is in the title bar of the report window. Typically, the report is in the working folder: slprj/modeladvisor/model_name.

Run the Model Advisor Programmatically

If you have a license for Simulink Verification and Validation, you can create MATLAB scripts and functions that run the Model Advisor programmatically. For example, you can create a function to check whether your model passes a specified set of the Model Advisor checks every time that you open the model and start a simulation. If you have Simulink Coder, the function can generate code from the model. For more information, see the ModelAdvisor.run function in the Simulink Verification and Validation documentation.

Check Support for Libraries

There are Model Advisor checks to verify the syntax of library models. When you use the Model Advisor to check a library model, the Model Advisor window indicates (~) checks that do not check libraries. To determine if you can run the check on library models, you can also refer to the check documentation, "Capabilities and Limitations". You cannot use checks that require model compilation. If you have a license for Simulink Verification and Validation, you can use an API to create custom checks which support library models.

Checks Triggering an Update Diagram

Model Advisor checks triggering an Update Diagram are marked with ^. An Update Diagram triggers a model compilation. Individual checks might require model compilation for either simulation or code generation.

Model Advisor Limitations

When you use the Model Advisor to check systems, the following limitations apply:

  • If you rename a system, you must restart the Model Advisor to check that system.

  • In systems that contain a variant subsystem, the Model Advisor checks only the active subsystem.

  • Checks do not search in model blocks or subsystem blocks with the block parameter Read/Write set to NoReadorWrite. However, on a check-by-check basis, Model Advisor checks do search in library blocks and masked subsystems.

For limitations that apply to specific checks, see the Limitations section within the documentation of each check.

Consult the Upgrade Advisor

Use the Upgrade Advisor to help you upgrade and improve models with the current release. The Upgrade Advisor can identify cases where you can benefit by changing your model to use new features and settings in Simulink. The Advisor provides advice for transitioning to new technologies, and upgrading a model hierarchy.

The Upgrade Advisor can also help identify cases when a model will not work because changes and improvements in Simulink require changes to a model.

The Upgrade Advisor offers options to perform recommended actions automatically or instructions for manual fixes.

You can open the Upgrade Advisor in the following ways:

  • From the Model Editor, select Analysis > Model Advisor > Upgrade Advisor

  • From the MATLAB command line, use the upgradeadvisor function:

    upgradeadvisor modelname
  • Alternatively, from the Model Advisor, click Upgrade Advisor. This action closes the Model Advisor and opens the Upgrade Advisor.

In the Upgrade Advisor, you create reports and run checks in the same way as when using the Model Advisor.

  • Select the top Upgrade Advisor node in the left pane to run all selected checks and create a report.

  • Select each individual check to open a detailed view of the results in the right pane. View the analysis results for recommended actions to manually fix warnings or failures. In some cases, the Upgrade Advisor provides mechanisms for automatically fixing warnings and failures.

    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 Upgrade Advisor might report an invalid check result.

You must run upgrade checks in this order: first the checks that do not require compile time information and do not trigger an Update Diagram, then the compile checks. To guide you through upgrade checks to run both non-compile and compile checks, run the check Analyze model hierarchy and continue upgrade sequence. See Analyze model hierarchy and continue upgrade sequence.

For more information on individual checks, see

.

Was this topic helpful?