Enable Coverage and Select Metrics
Before you analyze coverage results for your model, you need to enable coverage and decide which coverage metrics you want to see.
Open the Model
Open the slvnvdemo_powerwindow model. The slvnvdemo_powerwindow model contains a power window controller and a low-order plant model. The controller is implemented with a Stateflow® chart.
Choose Your Coverage Metrics
On the Apps tab, select Coverage Analyzer. Then, on the Coverage tab, click Settings to open the Configuration Parameters window. In the left pane, click Coverage. Select Enable coverage analysis. By default, the scope of the coverage analysis is set to Entire system. If you want to collect coverage data for a specific referenced model or subsystem, select your desired coverage scope and click Select Models or Select Subsystem. For this example, select Entire system.
The Structural coverage level parameter has four settings:
Block ExecutionWhether each block is executed during simulation.
DecisionAnalyzes decision points in your model. A decision is a place in your model where one or more input signals decide the output signal of a block. Selecting
Decisioncoverage also collectsBlock Executioncoverage.Condition DecisionAnalyzes blocks that output the logical combination of their input. A condition is a Boolean expression that does not contain Boolean operators. Selecting
Condition Decisioncoverage also collectsBlock Executioncoverage.Modified Condition Decision Coverage (MCDC)MCDC is condition decision coverage, except each condition must independently affect the decision outcome. Selecting
Modified Condition Decision Coverage (MCDC)also collectsCondition DecisionandBlock Executioncoverage.
For this example, set Structural coverage level to
Modified Condition Decision Coverage (MCDC).
For a full list of coverage metrics, including advanced metrics, see Types of Model Coverage.
Command-Line Information
You can also perform the steps in this example programmatically. Use
sim with a Simulink.SimulationInput object
to set the coverage model parameters for a simulation.
openExample('shared_vnv/GetStartedWithSimulinkCoverageExample') modelName = 'slvnvdemo_powerwindow'; open_system(modelName) simIn = Simulink.SimulationInput(modelName); simIn = setModelParameter(simIn,'CovEnable','on'); simIn = setModelParameter(simIn,'CovScope','EntireSystem'); simIn = setModelParameter(simIn,'CovMetricStructuralLevel','MCDC'); simIn = setModelParameter(simIn,'CovSaveSingleToWorkspaceVar','on'); simIn = setModelParameter(simIn,'CovSaveName','covData');