Main Content

slcoverage.Selector class

Package: slcoverage

Get selectors of all types


Use the slcoverage.Selector class with the allSelectors method to return all types of the selectors for a block.


expand all

This property is read-only.

Code used to create this selector object, returned as a character vector.

This property is read-only.

Description of the selector, returned as a character vector. Simulink® Coverage™ creates the description based on the selector.

This property is read-only.

Identifier of the model element, returned as character vector of the Simulink ID or a handle.

This property is read-only.

Selector type, returned as a selector type of the corresponding selector.


allSelectorsSelectors for model or code element

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.


collapse all

This example shows how to get all the selectors for an And block and then add a rule to justify or exclude a selector. Metric selectors can only be justified.

Move the current MATLAB® directory to the location that contains the example files.


Load the model and set coverage settings

modelName = 'slvnvdemo_covfilt';

First, get the block handle for the And block.

id = getSimulinkBlockHandle([modelName,'/Saturation']);

Get the selectors using the block handle.

sel = slcoverage.Selector.allSelectors(id)
sel = 

  1x10 heterogeneous Selector (BlockSelector, MetricSelector) array with properties:


The block has eight selectors. You can index into each one to see their contents. In this example, you want to justify the sixth selector.

ans = 

  MetricSelector with properties:

     ObjectiveIndex: 2
       OutcomeIndex: 2
        Description: 'T outcome of input >= upper limit in Saturate block "Saturation"'
               Type: DecisionOutcome
                 Id: 'slvnvdemo_covfilt:5'
    ConstructorCode: 'slcoverage.MetricSelector(slcoverage.MetricSelectorType.DecisionOutcome, 'slvnvdemo_covfilt:5', 2, 2)'

Create a justify rule, then create a filter object and add the rule to it.

rule = slcoverage.FilterRule(sel(6),'Expected result');
filt = slcoverage.Filter;

Save the filter and generate a coverage report.'metrfilter');
csim = cvsim(modelName);
csim.filter = 'metrfilter';
Introduced in R2017b