%% Collect Signal Range Data for a Block
% This example shows how to extract signal range info from a coverage data
% object.

% Copyright 2020 The MathWorks, Inc.

%% Load the model and set up coverage options
% Load the model into memory. This example uses a small controller model.
%

modelName = 'slvnvdemo_cv_small_controller';
load_system(modelName)

%%
% Declare coverage settings using a structure of parameter names and
% values. For a complete list of coverage parameters and their possible
% values, see <docid:slcoverage_ref#buwlv0o-1 Coverage Settings>.
%

covOpts.CovEnable = 'on';
covOpts.CovSaveSingleToWorkspaceVar = 'on';
covOpts.CovSaveName = 'covData';
covOpts.CovMetricSignalRange = 'on';

%% 
% Simulate the model using <docid:simulink_ref#bvfe92n |sim|> with the
% model name and the parameter structure as inputs.
%

simOut = sim(modelName,covOpts);

%% Get signal range data
% Get the block handle of the Product block using
% <docid:simulink_ref#btqy0ez |get_param|>.
%

bHandle = get_param([modelName,'/Product'],'Handle');

%%
% Get the signal range data by calling |sigrangeinfo| with the |cvdata|
% object and the block handle as inputs.
%

[minVal, maxVal] = sigrangeinfo(covData,bHandle)