Exclude Blocks From the Model Advisor Check Analysis

Model Advisor Exclusion Overview

To save time during model development and verification, you can limit the scope of the Model Advisor analysis of your model. You can create a Model Advisor exclusion to exclude blocks in the model from selected checks. You can exclude all or selected checks from:

  • Simulink® blocks

  • Stateflow® charts

After you specify the blocks to exclude, Model Advisor uses the exclusion information to exclude blocks from specified checks during analysis. By default, Model Advisor exclusion information is stored in the model SLX file. Alternatively, you can store the information in an exclusion file.

To view exclusion information for the model, right-click in the model window or right-click a block and select Model Advisor > Open Model Advisor Exclusion Editor.

The Model Advisor Exclusion Editor dialog box includes the following information for each exclusion.

FieldDescription
Filter Identifier

Name and path of the block or subsystem that is excluded. The path of the blocks are hyper-linked and clicking on them will highlight the concerned blocks on the model canvas.

Filter Type

Defines the type of the excluded item.

Example: If the filter type is Block, on that particular Simulink block is excluded. If the type is Subsystem, then all the contents inside that subsystem are excluded.

Summary

Editable field to enter notes or the reason for exclusion. By default, this field defines whether a specific block is excluded or all blocks of a given type are excluded.

Check ID (s)

Names of the checks for which the block exclusion applies. Check Selector can be invoked from this cell by clicking on the edit () button.

Note

If you comment out blocks, they are excluded from both simulation and Model Advisor analysis.

Create Model Advisor Exclusions

  1. In the model window, right-click a block and select Model Advisor. Select the menu option for the type of exclusion that you want to do.

    Task Select Model Advisor >
    Exclude the block from all checks.

    Exclude block only > All Checks

    Exclude all blocks of this type from all checks.

    Exclude all blocks of type <block_type> > All Checks

    Exclude the block from selected checks.
    1. Exclude block only > Select Checks.

    2. In the Check Selector dialog box, select the checks. Click OK.

    Exclude all blocks of this type from selected checks.
    1. Exclude all blocks of type <block_type> > Select Checks.

    2. In the Check Selector dialog box, select the checks. Click OK.

    Exclude the block from all failed checks. This option is available only after a Model Advisor analysis.

    Exclude block only > Only failed checks

    Exclude all blocks of this type from all failed checks. This option is available only after a Model Advisor analysis.

    Exclude all blocks of type <block_type> > Only failed checks

    Exclude the block from a failed check. This option is available only after a Model Advisor analysis.

    Exclude block only > <name of failed check>

    Exclude all blocks of this type from a failed check. This option is available only after a Model Advisor analysis.

    Exclude all blocks of type <block_type> > <name of failed check>

  2. In the Model Advisor Exclusion Editor dialog box, save the exclusions to the model or an exclusion file by using one of the processes below.

You can create as many Model Advisor exclusions as you want by right-clicking model blocks and selecting the options under Model Advisor.

Save Model Advisor Exclusions in a Model File

To save Model Advisor exclusions to the model .slx file, in the Model Advisor Exclusion Editor dialog box, click on the save icon(). When you open the model .slx file, the model contains the exclusions.

Save Model Advisor Exclusions in Exclusion File

A Model Advisor exclusion file specifies the collection of blocks to exclude from specified checks in an exclusion file. You can create exclusions and save them in an exclusion file.

To save Model Advisor exclusions to the exclusion .xml file:

  1. Open the Model Advisor Exclusion Editor.

  2. click the drop-down next to the save icon().

  3. Select Save as and enter the desired name for the exclusion file in the File name field.

  4. Click Save.

Unless you specify a different folder, the Model Advisor saves exclusion files in the current folder.

If you create an exclusion file and save your model, you attach the exclusion file to your model. Each time that you open the model, the blocks and checks specified in the exclusion file are excluded from the analysis.

Check Selector

The Check Selector window allows you to select the checks to exclude for a specific block or all blocks of a specified type. Open the Check Selector by right-clicking a block and selecting either:

  • Model Advisor > Exclude block only > Select checks

  • Model Advisor > Exclude all blocks of type <block_type> > Select checks

In the Check Selector, you can use the search functionality to search for a check that needs to be excluded. Check Selector can be also invoked from the Model Advisor Exclusion Editor window by clicking on the edit () button in the Check Id(s) column.

Review Model Advisor Exclusions

You can review the exclusions associated with your model. Before or after a Model Advisor analysis, to view exclusions information:

  • Right-click in the model window or right-click a block and select Model Advisor > Open Model Advisor Exclusion Editor. The Model Advisor Exclusion Editor dialog box lists the exclusions for your model.

  • In the Modeling tab, open Model Advisor > Preferences. In the Model Advisor Preferences dialog box, select Show Exclusion tab. In the right pane of the Model Advisor window, select the Exclusions tab to display checks that are excluded from the Model Advisor analysis.

  • In the Modeling tab, select Model Advisor to open the Model Advisor.

    1. On the Model Advisor window toolbar, select Highlighting > Highlight Exclusions. By default, this menu option is selected.

    2. In the Model Advisor window, click Enable highlighting ().

After the Model Advisor analysis, you can view exclusion information for individual checks in the:

  • HTML report. Before the analysis, in the Model Advisor window, make sure that you select the Show report after run check box.

  • After you run the checks, in the left pane of the Model Advisor window, the checks that contain exclusion rules are highlighted in orange. The Model Advisor results include additional information about the exclusion.

    If the checkThe HTML report and Model Advisor window
    Has no exclusions rules applied. Show that no exclusions were applied to this check.
    Does not support exclusions.Shows that the check does not support exclusions.
    Is excluded from a block.Lists the check exclusion rules.

Manage Exclusions

Load an Exclusion File

To load an existing exclusion file for use with your model:

  1. In the Model Advisor Exclusion Editor dialog box, click Load icon.

  2. Navigate to the exclusion file that you want to use with your model. Select Open.

  3. In the Model Advisor Exclusion Editor dialog box, click OK to associate the exclusion file with your model.

Remove an Exclusion

  1. In the Model Advisor Exclusion Editor dialog box, select the exclusions that you want to remove.

  2. Click the Delete Exclusion Row button ().

Add Summary to an Exclusion

You can add text that describes why you excluded a particular block or blocks from selected checks during Model Advisor analysis. A description is useful to others who review your model.

  1. In the Model Advisor Exclusion Editor dialog box, double-click the Summary field for the exclusion.

  2. Delete the existing text.

  3. Add the summary for excluding this object.

Compatibility Considerations after R2020b

In R2020b, the format in which exclusions are stored changed. In releases after R2020b, Model Advisor can read format used in previous releases, and convert it to new format. Conversion happens only once. The model is updated with the new file path, which Exclusion editor subsequently uses.

When you open a exclusion file created in R2020a or earlier, the files and models are updated based on whether the exclusion file was saved in the model or as a separate file, following are the sequence of actions that will be performed in each case:

Exclusion File Saved Inside the Model

  1. The original exclusion file is read and written to a new file.

  2. The new file is saved in the model SLX file when you save the model.

These changes are done automatically, and without notification that the file has been updated.

Exclusion File Is Saved in a Separate Exclusion File

  1. The old file is read and, you can choose to overwrite the existing exclusion file or save the exclusion file with a new name in the same location.

  2. The model updates the new file path when you save the model.

The Exclusion Editor reports that a change has taken place.

Programmatically Change Model Advisor Exclusions

The Model Advisor Exclusion file path is tracked by a model parameter called MAModelFilterFile. Use the set_param API to update this parameter.

set_param('<model name>','MAModelFilterFile', '<new_file_path>');

After the model is saved and reopened, the changes are reflected in the Exclusion Editor. If <new_file_path> is an empty character vector, Model Advisor Exclusion Editor assumes the file is stored inside the model SLX file.

Exclude Blocks from Edit Time Checking

While editing a model, you can exclude blocks from Model Advisor analysis. Applicable Model Advisor exclusions specified through the Simulink editor are also applied during edit-time.

To exclude a block from Model Advisor analysis during edit-time:

  1. From the command prompt, open sldemo_fuelsys.

  2. Introduce a warning that is visible in edit-time checking. Add the number 9 to the beginning of the Engine Speed block name, which results in a violation of Model Advisor check Check character usage in block names.

  3. In the Modeling tab, select Edit-Time Checks. Multiple blocks are flagged as Model Advisor check violations.

    For instance, the Engine Speed block is highlighted and, when you click the warning icon above the block, you see that the cause of the violation is Block name has incorrect characters.

  4. To exclude the Engine Speed block from Model Advisor analysis, either:

    1. Right-click the block, select Model Advisor > Exclude block only > Select checks, and select the check.

    2. Click the warning icon above the highlighted Engine Speed block. In the diagnostic window, select Suppress.

    The block is excluded from Model Advisor analysis for that check and is not highlighted for check violation.

    Note

    The list of exclusions is shared between all executions of the Model Advisor checks.

Limit Model Checks by Excluding Gain and Outport Blocks

This example shows how to exclude a Gain block and all Outport blocks from a Model Advisor check during a Model Advisor analysis. By excluding individual blocks from checks, you limit the scope of the analysis and might save time during model development and verification.

  1. At the MATLAB® command line, type sldemo_mdladv.

  2. From the model window, in the Modeling tab, select Model Advisor to open the Model Advisor. A System Selector - Model Advisor dialog box opens. Click OK.

  3. In the left pane of the Model Advisor window, expand By Product > Simulink. Select the Show report after run check box to see an HTML report of check results after you run the checks.

  4. Note

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

  5. 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. The check Identify unconnected lines, input ports, and output ports triggers a warning.

  6. In the left pane of the Model Advisor window, select the check By Product > Simulink > Identify unconnected lines, input ports, and output ports.

  7. In the Model Advisor window, click the Enable highlighting button ().

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

  8. After reviewing the check results, exclude the Gain2 block from all Model Advisor checks:

    1. In the model window, right-click the Gain2 block and select Model Advisor > Exclude block only > All checks .

    2. In the Model Advisor Exclusion Editor dialog box, double-click in the first row of the Summary field, and enter Exclude gain block.

    3. Click OK to store the exclusion in the model file.

  9. After reviewing the check results, exclude all Outport blocks from the Identify unconnected lines, input ports, and output ports check:

    1. Right-click the Out4 block and select Model Advisor > Exclude all blocks of type Outport > Identify unconnected lines, input ports, and output ports.

    2. In the Model Advisor Exclusion Editor dialog box, click OK to store the exclusion in the model file.

  10. In the left pane of the Model Advisor window, select By Product > Simulink and then:

    • Select the Show report after run check box.

    • Click Run Selected Checks to run a Model Advisor analysis.

  11. After the Model Advisor completes the analysis, you can view exclusion information for the Identify unconnected lines, input ports, and output ports check in the:

    • HTML report:

    • Model Advisor window. In the left pane of the Model Advisor window, select By Product > Simulink > Identify unconnected lines, input ports, and output ports.

  12. Close sldemo_mdladv.

Related Examples

More About