Main Content

Exclude Blocks from 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:

  • Filter Identifier

  • Filter Type

  • Summary

  • Check ID(s)

Model Advisor Exclusion Editor window

FieldDescription
Filter Identifier

Name and path of the block or subsystem that is excluded. The path of the blocks are hyperlinked 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.

Filter Types

Filter type defines the type of the excluded entity. Model Advisor Exclusion Editor currently supports exclusion of the following entities:

Filter TypeDescription
Simulink
BlockExclude a Simulink block.
BlockTypeExclude all blocks of a type.
SubsystemExclude all blocks inside a subsystem.
LibraryExclude all instances of a library block.
MaskTypeExclude blocks or subsystem of mask type.
StateflowExclude Stateflow blocks in Simulink.
Stateflow
ChartExclude every entity inside a Stateflow Chart.
StateExclude a Stateflow State.
TransitionExclude a Stateflow Transition.
JunctionExclude a Stateflow Junction.
GraphicalFunctionExclude a Stateflow Graphical Function.
MATLABFunctionExclude a Stateflow MATLAB® Function.
SimulinkFunctionExclude a Stateflow Simulink Function.
TruthTableExclude a Stateflow Truth Table.
SimulinkBasedStateExclude a Simulink based state in Stateflow.

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

Check Selector window with no checks selected

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.

  • After the Model Advisor analysis, you can view exclusion information for individual checks in the report file.

    • 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 the Open exclusions file button .

  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 exclusion 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 Editor can now be used with the following functions:

TaskFunction
Add a new exclusion in Model Advisor.Advisor.addExclusion
Remove exclusions from Model Advisor.Advisor.removeExclusion
Clear all exclusions from Model Advisor.Advisor.clearExclusion
Get exclusions for a model or a filter.Advisor.getExclusion
Save exclusions to the default option or to a new file.Advisor.saveExclusion
Load default exclusions stored inside the model or according to the path settings.Advisor.loadExclusion

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.

Related Examples

More About