Retrieve lookup table coverage
Retrieve Lookup Table Coverage Information
Collect lookup table coverage for the
model and determine the percentage of
interpolation/extrapolation intervals coverage
collected for the Gain Table block in the Gain
mdl = 'slvnvdemo_cv_small_controller'; open_system(mdl) %Create test spec object testObj = cvtest(mdl) %Enable lookup table coverage testObj.settings.tableExec = 1; %Simulate the model data = cvsim(testObj) blk_handle = get_param([mdl, '/Gain/Gain Table'], 'Handle'); %Retrieve l/u table coverage cov = tableinfo(data, blk_handle) %Percent MCDC outcomes covered percent_cov = 100 * cov(1) / cov(2)
cvdo — Coverage data
Coverage data, specified as a
modelObject — Model object
character array |
string array |
Simulink® handle |
Stateflow® ID |
Model object, specified as a character array, string array, Simulink handle, Stateflow ID, or cell array.
To specify a model object, for example a block or a Stateflow chart, use one of the following formats:
Full path to a model or block
Handle to a model or block
Handle to a Simulink API object
Handle to a Stateflow API object from a singly instantiated Stateflow chart
Cell array with the path to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart
Cell array with the path to a Stateflow chart or subchart and a Stateflow object API handle contained in that chart or subchart
Cell array with a handle to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart
To specify an S-Function block or its contents, use one of the following formats:
Cell array with the path to an S-Function block and the name of a source file
Cell array with an S-Function block handle and the name of a source file
Cell array with the path to an S-Function block, the name of a source file, and a function name
Cell array with an S-Function block handle, the name of a source file an a function name
To specify a code coverage result, for example coverage data collected during software-in-the-loop (SIL) or processor-in-the-loop (PIL) analysis, use one of the following formats:
Cell array with the name of a source file and a function name
Cell array with a model name or model handle and the name of a source file
Cell array with a model name or model handle, the name of a source file, and a function name
ignore_descendants — Whether to ignore descendants in coverage results
0 (default) |
Whether to ignore descendants in coverage results, specified as
0includes coverage results of descendant objects.
1ignores coverage results of descendant objects.
covInfo — Coverage information
Coverage information, returned as a
two-element array of the form
cvdo contains lookup table
coverage data, or an empty array if it does
|Number of interpolation/extrapolation
intervals satisfied for
|Total number of interpolation/extrapolation
exeCounts — Execution count
Execution count, returned as an array of
execution counts for each interpolation and
extrapolation interval in the lookup table block.
exeCounts has one more entry
in each dimension than the lookup table
brkEquality — Breakpoint equality flag
Breakpoint equality flag, returned as a cell array. Each cell contains a vector which identifies the number of times during simulation the lookup table block input is equivalent to a breakpoint value. Each vector represents the breakpoints along a different lookup table dimension.
Use the coverage settings to collect lookup table coverage for a model:
Open the model.
In the Model Editor, select Model Settings on the Modeling tab.
On the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.
Under Coverage metrics, select Lookup Table.
Click OK to close the Configuration Parameters dialog box and save your changes.
Simulate the model by clicking the Run button and review the results.