Main Content

Advisor.addExclusion

Add exclusions to model or exclusion file

Since R2021a

Description

Advisor.addExclusion(modelName,filterType,entityIdentifier) adds an exclusion to an entity, like a block, subsystem, or Stateflow® element, in the model modelName. The type of exclusion is specified by the filterType argument. The entity is specified by the entityIdentifier argument.

If you add an exclusion, you can save time during model development and verification because you limit the scope of the analysis that Model Advisor has to perform on your model.

example

Advisor.addExclusion(___,Name,Value) specifies options using one or more name-value arguments in addition to the input arguments in previous syntaxes. For example, you can use the checks argument to exclude an entity from specific Model Advisor checks or the rationale argument to provide a reason for the exclusion.

example

Examples

collapse all

Use the Advisor.addExclusion function to exclude a Simulink® block from Model Advisor analysis.

Open the slexAircraftExample model.

openExample('simulink_aerospace/AircraftLongitudinalFlightControlExample')

On the Simulink canvas, click the entity that you want to exclude from Model Advisor checks. For this example, click the Inport block named u.

Simulink canvas with "u" Inport block selected

Exclude the selected block from Model Advisor analysis by adding an exclusion to the block. In the MATLAB® Command Window, enter:

Advisor.addExclusion('slexAircraftExample','Block',gcb);
'Block' specifies that the exclusion needs to filter out a Simulink block and the function gcb returns the path to the block that you selected. For more information, see gcb.

You can view the exclusion in the Model Advisor Exclusion Editor by right-clicking the Simulink canvas and selecting Model Advisor > Open Model Advisor Exclusion Editor.

The Model Advisor Exclusion Editor shows a table with a row for the u Inport block exclusion. The Filter Identifier column shows the pathname specified by the entityIdentifier argument and the Filter Type column shows the exclusion filter type specified by filterType argument. The Rationale and Check ID(s) columns are associated with the rationale and checks arguments.

Model Advisor Exclusion Editor with exclusion for "u" Inport block

Use the Advisor.addExclusion function to exclude a Stateflow chart from the Model Advisor analysis. This example requires Stateflow.

Open the sf_collatz model.

openExample('stateflow/StateTransitionActionsGetStartedExample')

In the Stateflow chart, click the entity that you want to exclude from Model Advisor checks. For this example, click the default transition {n = u;}.

Stateflow chart with default transition selected

Exclude the selected transition from Model Advisor analysis by adding an exclusion to the transition. In the MATLAB Command Window, enter:

Advisor.addExclusion('sf_collatz','Transition',gcb,'rationale','Do not analyze.')

You can view the exclusion in the Model Advisor Exclusion Editor by right-clicking the Simulink canvas and selecting Model Advisor > Open Model Advisor Exclusion Editor.

Input Arguments

collapse all

Model to add the exclusion to, specified as a character vector or string array.

Data Types: char | string

Type of entity to exclude, specified as one of these values.

ValueDescription
BlockSimulink block
BlockTypeBlocks with a specific BlockType property value
SubsystemBlocks inside a subsystem
LibraryInstances of a library block
MaskTypeBlocks or subsystems with a specific MaskType property value
StateflowStateflow blocks in Simulink
ChartEvery entity inside Stateflow chart
StateStateflow State
TransitionStateflow Transition
JunctionStateflow Junction
GraphicalFunctionStateflow Graphical Function
MatlabFunction

Stateflow MATLAB Function

SimulinkFunction

Stateflow Simulink Function

TruthTableStateflow Truth Table
SimulinkBasedStateSimulink based state in Stateflow

Example: Advisor.addExclusion('mymodel', 'Block', 'mymodel/Constant')

Data Types: char | string

Identifier for the entity that you want to exclude, specified as a BlockType property value, MaskType property value, or pathname.

The format of the entityIdentifier value depends on which filterType you specified.

filterType valueentityIdentifier valueExample
BlockType

Value of the BlockType property for the block

Use the function gcb to get the currently selected block and get_param to get the block type.

myblock = gcb;
blockType = get_param(myblock,'BlockType');
Advisor.addExclusion('mymodel','BlockType',blockType);

MaskType

Value of the MaskType property for the block

Use the function gcb to get the current block and get_param to get the mask type.

blockWithMask = gcb;
maskType = get_param(blockWithMask,'MaskType');
Advisor.addExclusion('mymodel','MaskType',maskType);

All other filterType valuesPathname for the entity

You can use the functions gcb or find_system to get the pathname for an entity.

myblock = gcb;
Advisor.addExclusion('mymodel','Block',myblock)

Example: Advisor.addExclusion('mymodel','BlockType',blockType)

Example: Advisor.addExclusion('mymodel','MaskType',maskType)

Example: Advisor.addExclusion('mymodel','Block','mymodel/Constant')

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: Advisor.addExclusion('mymodel', 'BlockType', 'Integrator', 'checks', {'mathworks.jmaab.jc_0231', 'mathworks.jmaab.jc_0222'}, 'validateChecks', true);

Checks that the exclusion applies to, specified as a cell array of Model Advisor check IDs.

By default, when you add an exclusion to an entity, the exclusion applies to all checks. You can use the checks argument to exclude only the selected checks.

Example: Advisor.addExclusion('mymodel','Block','mymodel/Constant','checks',{'mathworks.design.UnconnectedLinesPorts'})

Example: Advisor.addExclusion('mymodel','Block','mymodel/Constant','checks',{'mathworks.jmaab.jc_0231','mathworks.design.UnconnectedLinesPorts'})

Data Types: cell

Validate that the checks specified by the checks argument can be excluded, specified as a numeric or logical 0 (false) or 1 (true).

Certain checks, like Check usage of enumerated values, do not allow exclusions. If you specify validateChecks as true, Model Advisor warns that the check does not support exclusions.

Advisor.addExclusion('vdp','Block',gcb,...
'checks',{'mathworks.jmaab.jc_0231','mathworks.maab.na_0031'},..
'validateChecks',true);
The following checks do not support exclusions:
    {'mathworks.maab.na_0031'}

Example: Advisor.addExclusion('mymodel','Block','mymodel/Constant','checks',{'mathworks.jmaab.jc_0231','mathworks.maab.na_0031'},'validateChecks',true)

Data Types: logical

Reason for exclusion, specified as a character vector or string array.

Example: Advisor.addExclusion('mymodel','Block','mymodel/Constant','rationale','Block to be removed later.')

Data Types: char | string

Alternative Functionality

Model Advisor Exclusion Editor

You can also add exclusions from the Simulink canvas by using the Model Advisor Exclusion Editor. To add an exclusion from the Simulink canvas, right-click an entity, select Model Advisor, and select the menu option for the type of exclusion that you want to add. For more information, see Exclude Blocks from Model Advisor Check Analysis.

Version History

Introduced in R2021a

expand all