Retrieve cyclomatic complexity coverage information from cvdata object
complexity = complexityinfo(cvdo, object)
The object argument specifies an object in the model or Stateflow® chart that received decision coverage. Valid values for object include the following:
If cvdo does not contain cyclomatic complexity coverage results for object, complexity is empty.
If cvdo contains cyclomatic complexity coverage results for object, complexity is a two-element vector of the form [total_complexity local_complexity]:
If object has variable-size signals, complexity also contains the variable complexity.
Open the sldemo_fuelsys model and create the test specification object testObj. Enable decision, condition, and MCDC coverage for sldemo_fuelsys and execute testObj using cvsim. Use complexityinfo to retrieve cyclomatic complexity results for the Throttle subsystem. The Throttle subsystem itself does not record cyclomatic complexity coverage results, but the contents of the subsystem do record cyclomatic complexity coverage.
mdl = 'sldemo_fuelsys'; open_system(mdl); testObj = cvtest(mdl) testObj.settings.decision = 1; testObj.settings.condition = 1; testObj.settings.mcdc = 1; data = cvsim(testObj); blk_handle = get_param([mdl, ... '/Engine Gas Dynamics/Throttle & Manifold/Throttle'],... 'Handle'); coverage = complexityinfo(data, blk_handle); coverage
Use the Coverage Settings dialog box to collect and display cyclomatic complexity coverage results in the coverage report:
Open the model.
In the Model Editor, select Analysis > Coverage > Settings.
On the Coverage tab, select Coverage for this model.
Under Coverage metrics, select:
On the Reporting tab, click HTML Settings.
In the HTML Settings dialog box, select:
Include cyclomatic complexity numbers in summary
Include cyclomatic complexity numbers in block details
Click OK to close the HTML Settings dialog box and save your changes.
Click OK to close the Coverage Settings dialog box and save your changes.
Simulate the model and review the results in the HTML report.