User`s guide

18 Coverage Collection During Simulation
18-46
Have a Stateflow license.
Have debugging/animation enabled for the chart.
Specify Coverage Report Settings
To specify coverage report settings, select Analysis > Coverage > Settings in the
Simulink Editor.
By selecting the Generate HTML Report option in the Coverage Settings dialog
box, you can create an HTML report containing the coverage data generated during
simulation of the model. The report appears in the MATLAB Help browser at the end of
simulation.
By selecting the Generate HTML Report option, you also enable the selection of
different coverages that you can specify for your reports. The following sections address
only coverage metrics that affect reports for Stateflow charts. These metrics include
decision coverage, condition coverage, and MCDC coverage.
Cyclomatic Complexity
Cyclomatic complexity is a measure of the complexity of a software module based on its
edges, nodes, and components within a control-flow chart. It provides an indication of
how many times you need to test the module.
The calculation of cyclomatic complexity is as follows:
CC = E - N + p
where CC is the cyclomatic complexity, E is the number of edges, N is the number of
nodes, and p is the number of components.
Within the Model Coverage tool, each decision is exactly equivalent to a single control
flow node, and each decision outcome is equivalent to a control flow edge. Any additional
structure in the control-flow chart is ignored since it contributes the same number of
nodes as edges and therefore has no effect on the complexity calculation. Therefore, you
can express cyclomatic complexity as follows:
CC = OUTCOMES - DECISIONS + p