Main Content

Advisor.getExclusion

Get exclusion information from model or exclusion file

Since R2021a

Description

exclusionInfo = Advisor.getExclusion(modelName) displays the 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

Add an exclusion to a model and then get the exclusion from the model.

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

Get the exclusions from the model by entering:

exclusions = Advisor.getExclusion('slexAircraftExample');

The exclusion that you add to the u Inport 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: 'slexAircraftExample: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 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 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 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.

Get the exclusion for the u Inport block by entering:

exclusion = Advisor.getExclusion('slexAircraftExample','Block',gcb)
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: 'slexAircraftExample: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 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

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