%% Add Rule to a Filter File
% This example shows how to add a rule to a coverage filter file.

% Copyright 2020 The MathWorks, Inc.

%%
% Create a filter object and use the |BlockSelector| class to create a
% |BlockSelector| object for the Saturation block in the
% |slvnvdemo_covfilt| model.

filt = slcoverage.Filter;
blockSel = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockInstance,...
           'slvnvdemo_covfilt/Saturation');

%%
% Create a rule to filter the Saturation block using
% |slcoverage.FilterRule| with the selector as the first input and the
% rationale as the second input.

rule = slcoverage.FilterRule(blockSel,'Edge case');

%%
% Use the |addRule| method of the |slcoverage.Filter| class to add the rule
% to the filter object.

addRule(filt,rule);

%%
% Save the filter with the new rule to a filter file using the |save|
% method of the |slcoverage.Filter| class.

save(filt,'myFilterFile')
