Check Model Compliance by Using the Model Advisor

You can use the Model Advisor to check a model or subsystem for adherence to modeling guidelines or standards. The Model Advisor includes checks that help you define and implement consistent design guidelines. Using model checks, you can apply guidelines across projects and development teams.

You can use the Model Advisor to check your model in these ways:

  • After you complete your model design, run Model Advisor checks interactively.

  • Configure the Model Advisor to check for violations while you edit.

When you use the Model Advisor to check systems, these 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.

  • Model Advisor does not analyze commented blocks.

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

  • Unless specified in the documentation for a check, the Model Advisor, by default, does not analyze the contents of a Model Reference block. To run checks on referenced models, use instances of the Advisor.Application class.

Check Your Model Interactively by Using Model Advisor Checks

You can use the Model Advisor to check your model interactively against modeling standards and guidelines. In the model window, select Analysis > Model Advisor > Model Advisor. Select the model or system that you want to review. Select the checks that you want to run on your model from the By Product or By Task folders. Then run your selected checks. The Model Advisor reviews your model and, if selected, displays an HTML report of your results.

Depending on which products you have installed, the Model Advisor includes different checks.

For More InformationSee
Checking model compliance with the DO-178C safety standardModel Checks for DO-178C/DO-331 Standard Compliance
Checking model compliance with the IEC 61508, IEC 62304, ISO 26262, or EN 50182 safety standardsModel Checks for IEC 61508, IEC 62304, ISO 26262, and EN 50128 Standard Compliance
Checking model compliance with MathWorks® Automotive Advisory Board (MAAB) guidelinesModel Checks for MathWorks Automotive Advisory Board (MAAB) Guideline Compliance
Checking model compliance with the MISRA C:2012 standardModel Checks for MISRA C:2012 Compliance
Checking model compliance with CERT C, CWE, and ISO/IEC TS 17961 secure coding standardsModel Checks for Secure Coding (CERT C, CWE, and ISO/IEC TS 17961 Standards)
Checking requirements links Model Checks for Requirements Links
Checking model metricsCollect Model Metrics Using the Model Advisor

Check Your Model as You Edit by Using Edit-Time Checking

You can identify modeling guideline compliance issues earlier in the model design process by using edit-time checking. When using edit-time checking, the Model Advisor evaluates the model against a subset of Model Advisor checks. Highlighted blocks in the model editor window alert you to issues in your model.

View and Configure Edit-Time Checks

When you select edit-time checking, the Model Advisor evaluates the model against a subset of Model Advisor checks. To view and configure the Model Advisor checks that edit-time checking flags:

  1. In the model window, select Analysis > Model Advisor > Configure Advisor Edit-Time Checks.

  2. In the Model Advisor Configuration Editor, verify that the Edit-time Supported Checks item is selected from the Show drop-down list. The filtered list identifies the model advisor checks that are flagged.

  3. Select or clear checks as needed. Selected checks are included in the edit-time check analysis. You can use the Input Parameters options to customize each check.

  4. If you have made updates to check selection or behavior, save the current configuration. Then select File > Set Current Configuration as Default.

    Note

    Only the default configuration can change the behavior of edit-time checks.

To customize the behavior of edit-time checks, configure updates in the filtered view of edit-time checks in the Model Advisor Configuration Editor. If a check appears in multiple folders of your Model Advisor tree, for edit-time checking, Model Advisor assigns priority to the check in your custom folder. If the check is not in your custom folder, priority goes to the check in the By Task folder, and finally to the check in your By Product folder.

Use Edit-Time Checking to Highlight Compliance Issues in the Model Editor

When using edit-time checking, the Model Advisor highlights blocks that violate the Model Advisor checks. To enable edit-time checking of your model, in the model window, select Analysis > Model Advisor > Display Advisor Checks in Editor.

Place your cursor over a highlighted block and click the error or warning icon.

The Model Advisor identifies compliance issues in the block that violate edit-time checks. When a block has multiple check violations, you can move between the edit-time violations by using the << and >> buttons. For each issue, you can:

  • Review the cause .

  • Click the question mark to access detailed documentation about the flagged Model Advisor check.

  • Ignore a warning for a block and add the block to the exclusion list for that check by clicking the Ignore button.

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 https://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, 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.

In this example, you use edit-time checking to verify compliance of Stateflow charts with the MAAB guidelines while you edit:

  1. Open your model that contains Stateflow charts. For example, at the command prompt, open model sf_boiler.

  2. To enable the edit-time checking, go to Analysis > Model Advisor > Display Advisor Checks in Editor.

  3. Open the Bang-Bang Controller chart by double-clicking it. The Model Advisor highlights multiple states. Place your cursor over the warning of the Off state to discover the issue.

  4. Select the warning. The Model Advisor indicates that there must be a new line after en: to comply with the MAAB guidelines. In your model, place your cursor after en: and press Enter. A new line is added and the warning is cleared.

Related Examples

More About