Main Content


Create HTML coverage report from model coverage objects


cvhtml(file,cvdo) creates an HTML report of the coverage results in the cvdata or cv.cvdatagroup object cvdo with the file name file. The model must be open when you call cvhtml.

cvhtml(file,cvdo1,...,cvdoN) creates a combined report from several cvdata objects. The results from each object appear in a separate column of the HTML report. Each cvdata object must correspond to the same root model or subsystem.

cvhtml(file,cvdo1,...,cvdoN,options) creates a combined report from several cvdata objects using the report options specified by options.

cvhtml(file,cvdo,simMode) creates an HTML report for the models that have the simulation mode simMode.

reportInfo = cvhtml(_) creates an output structure array, reportInfo, that contains the file names and paths for each report.


If you create a coverage report for a model reference hierarchy by using a cv.cvdatagroup object as the cvdo argument, cvhtml creates a report for each referenced model. cvhtml prepends the specified file name, file, to each child report.


collapse all

This example shows how to create a coverage report programmatically.

Load the model.

modelName = "slvnvdemo_cv_small_controller";

The slvnvdemo_cv_small_controller model is already configured to collect coverage. To make the coverage data accessible in the MATLAB® workspace, enable the CovSaveSingleToWorkspaceVar parameter by using a Simulink.SimulationInput object.

simIn = Simulink.SimulationInput(modelName);
simIn = setModelParameter(simIn,"CovSaveSingleToWorkspaceVar","on");

Simulate the model using simIn and extract the coverage data from the Simulink.SimulationOutput object.

simOut = sim(simIn);
covData = simOut.covdata;

Create a coverage report by using cvhtml.

rptFileName = "cv_small_controller_coverage.html";
reportInfo = cvhtml(rptFileName,covData)
reportInfo = 

  struct with fields:

          fileName: "cv_small_controller_coverage.html"
              path: "/tmp/Bdoc24a_2528353_1164626/tpe9a0e1b1/slcoverage-ex75072404"
    cvdataUniqueId: "571cc4a0-9502-4d2c-9da8-44510a0d2b83"

The optional reportInfo output argument displays the file and path names of the coverage report, as well as the unique ID of the cvdata object used to generate the report.

Input Arguments

collapse all

Coverage data, specified as a cvdata object or cv.cvdatagroup object.

Data Types: cvdata | cv.cvdatagroup

File name of the generated report, specified as a character array or string array. Specify the absolute path or relative path and the file name.

Report options, specified as a character vector or string that consists of an option from the table, an equal sign, and 0 or 1.

  • To enable an option, use 1.

Example: "-hTR=1"

  • To disable an option, use 0.

Example: "-sRT=0"

  • To specify multiple report options, list the options in a single character vector or string separated by commas or spaces.

Example: "-hTR=1 -bRG=0 -scm=0"



Show report



Web view mode



Include each test in the model summary



Show aggregated tests information in coverage report



Produce bar graphs in the model summary



Use two-color bar graphs



Display hit/count ratio in the model summary



Exclude execution metric details from report



Exclude fully covered model objects from report



Exclude fully covered model object details from report



Include cyclomatic complexity numbers in summary



Include cyclomatic complexity numbers in block details



Filter Stateflow® events from report



Include linked requirements in coverage report


Data Types: char | string

Simulation mode, specified as one of these values:

Object SpecificationDescription


Model in Normal simulation mode

"SIL" (or "PIL")

Model in software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation mode

"ModelRefSIL" (or "ModelRefPIL")

Model reference in SIL or PIL simulation mode

"ModelRefTopSIL" (or "ModelRefTopPIL")

Model reference in SIL or PIL simulation mode with code interface set to top model

Output Arguments

collapse all

Coverage report information, returned as a 1-by-N structure array, where N is the number of coverage reports. The structure array contains these fields.

Coverage report file name, returned as a string.

Example: "coverageReport.html"

Data Types: string

Coverage report file path, returned as a string.

Example: "C:\Documents\CovReports"

Data Types: string

Coverage data unique identifier, returned as a string. cvdataUniqueId is the uniqueId property of the cvdata object.

Example: "80ffeedf-67f1-4361-9d20-265672f1f5c6"

Data Types: string

Data Types: struct


Use the Simulink® Editor to generate a coverage report when you simulate the model:

  1. Open the model for which you want a model coverage report.

  2. In the Simulink Editor, in the Modeling tab, select Model Settings.

  3. In the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.

  4. Click OK.

  5. Click Run (Coverage) to simulate the model. When the simulation completes, the coverage report opens in the Coverage Details pane.

Version History

Introduced before R2006a

expand all