Main Content

Advisor.getExclusion

R2026b

Get exclusion information from model or exclusion file

Description

exclusionInfo = Advisor.getExclusion(modelName) displays all exclusion information for the model.

example

exclusionInfo = Advisor.getExclusion(modelName,filterType,entityIdentifier) gets the exclusion information for an entity, like a block, subsystem, or Stateflow® element, in the model. The type of exclusion is specified by the filterType argument. The entity is specified by the entityIdentifier argument.

example

Examples

collapse all

Create a model, add an exclusion to a block, and then get the exclusion from the model.

Create and open a model named myAdvisorModel.

modelName = 'myAdvisorModel';
new_system(modelName);
open_system(modelName);

Add a Gain block to the model.

add_block('simulink/Math Operations/Gain',[modelName '/Gain']);

Exclude the Gain block from Model Advisor analysis.

Advisor.addExclusion(modelName,'Block',[modelName '/Gain']);

Get all exclusions from the model.

exclusions = Advisor.getExclusion(modelName);

The exclusion for the Gain block is the first and only element in exclusions.

exclusions(1)
ans =

  AdvisorFilterSpecification with properties:
     filteredItem: [1×1 advisor.filter.IFilter]
         metadata: [1×1 advisor.filter.Metadata]
             mode: Exclude
    commentThread: [1×0 advisor.filter.Metadata Sequence]
             type: Block
               id: 'myAdvisorModel:1'
           checks: [1×1 String Sequence]

Alternatively, 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 Gain block exclusion. The Filter Identifier column shows the pathname of the excluded block and the Filter Type column shows Block. The Rationale and Check ID(s) columns are empty because no rationale or checks were specified.

Model Advisor Exclusion Editor showing a table with one row for the Gain block exclusion. The Filter Identifier column shows the block pathname, the Filter Type column shows Block, and the Rationale and Check ID(s) columns are empty.

Continue from the previous example to add a second exclusion with a rationale and then get the exclusion for that specific block using the filterType and entityIdentifier arguments.

Using the myAdvisorModel model from the previous example, add a Constant block and exclude it with a rationale.

add_block('simulink/Sources/Constant',[modelName '/Constant']);
Advisor.addExclusion(modelName,'Block',[modelName '/Constant'],'rationale','Block verified manually.');

Get the exclusion for the Constant block.

exclusion = Advisor.getExclusion(modelName,'Block',[modelName '/Constant'])
exclusion =

  AdvisorFilterSpecification with properties:
     filteredItem: [1×1 advisor.filter.IFilter]
         metadata: [1×1 advisor.filter.Metadata]
             mode: Exclude
    commentThread: [1×0 advisor.filter.Metadata Sequence]
             type: Block
               id: 'myAdvisorModel:2'
           checks: [1×1 String Sequence]

Alternatively, 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 Rationale column in the Model Advisor Exclusion Editor shows Block verified manually for the Constant block exclusion.

Model Advisor Exclusion Editor showing a table with two rows, one for the Gain block and one for the Constant block. The Rationale column shows Block verified manually for the Constant block exclusion.

Input Arguments

collapse all

Model to get exclusions from, specified as a character vector or string array.

Example: Advisor.getExclusion('mymodel');

Data Types: char | string

Type of entity to get the exclusions from, 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.getExclusion('mymodel', 'Block', 'mymodel/Constant')

Data Types: char | string

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

If you specified the filterType argument as:

  • BlockType, then specify a BlockType value.

    You can use the functions gcb and get_param to get the currently selected block and the block type. For example:

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

  • MaskType, then specify a MaskType value.

    You can use the functions gcb and get_param to get the currently selected entity and the mask type. For example:

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

  • Any other filterType argument, then specify the pathname for the entity.

    You can use the function gcb to get the pathname for an entity. For example:

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

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

Data Types: char | string

Output Arguments

collapse all

Exclusion information, returned as an AdvisorFilterSpecification object or advisor.filter.FilterSpecification Sequence. An advisor.filter.FilterSpecification Sequence contains an AdvisorFilterSpecification object for each exclusion.

Note

If the checks property in the displayed result is .*, then Model Advisor excludes the entity from all checks.

Alternative Functionality

Model Advisor Exclusion Editor

You can also view exclusions by using the Model Advisor Exclusion Editor. To view exclusion information for a model, right-click in the Simulink canvas or right-click an entity and select Model Advisor > Open Model Advisor Exclusion Editor. For more information, see Exclude Blocks from Model Advisor Check Analysis.

Version History

Introduced in R2021a

expand all