Retrieve cyclomatic complexity coverage information from
complexity = complexityinfo(cvdo, object)
complexity = complexityinfo(cvdo, object, mode)
When specifying an S-function block, valid values for
For coverage data collected during Software-in-the-Loop (SIL)
mode or Processor-in-the-Loop (PIL) simulation mode, valid values
This example shows how to retrieve cyclomatic complexity information for the Gain subsystem of the
modelName = 'slvnvdemo_cv_small_controller'; load_system(modelName);
Create a test specification object and enable decision, condition, and MCDC coverage. Then, simulate the model using
testObj = cvtest(modelName); testObj.settings.decision = 1; testObj.settings.condition = 1; testObj.settings.mcdc = 1; covData = cvsim(testObj);
Retrieve cyclomatic complexity information for the Gain subsystem.
gainPath = [modelName,'/Gain']; gainComplexity = complexityinfo(covData,gainPath)
gainComplexity = 1 0
The Gain subsystem itself does not record cyclomatic complexity, but the contents of the subsystem do. This can be seen in the results because the total complexity is 1, which includes the subsystem and all of its descendants. In contrast, the local complexity is 0, indicating that the one point of complexity comes from one of the descendants, in this case a Switch block.
switchPath = [modelName,'/Gain/Switch']; switchComplexity = complexityinfo(covData,switchPath)
switchComplexity = 1 1
Use the coverage settings to collect and display cyclomatic complexity coverage results in the coverage report:
Open the model.
In the Simulink 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 MCDC as the structural coverage level.
Click OK to close the Configuration Parameters dialog box and save your changes.
Simulate the model and review the results in the HTML report.