Documentation

mcdcinfo

Retrieve modified condition/decision coverage information from cvdata object

Syntax

coverage = mcdcinfo(cvdo, object)
coverage = mcdcinfo(cvdo, object, mode)
coverage = mcdcinfo(cvdo, object, ignore_descendants)
[coverage, description] = mcdcinfo(cvdo, object)

Description

coverage = mcdcinfo(cvdo, object) returns modified condition/decision coverage (MCDC) results from the cvdata object cvdo for the model component specified by object.

coverage = mcdcinfo(cvdo, object, mode) returns modified condition/decision coverage (MCDC) results from the cvdata object cvdo for the model component specified by object for the simulation mode mode.

coverage = mcdcinfo(cvdo, object, ignore_descendants) returns MCDC results for object, depending on the value of ignore_descendants.

[coverage, description] = mcdcinfo(cvdo, object) returns MCDC results and text descriptions of each condition/decision in object.

Input Arguments

cvdo

cvdata object

ignore_descendants

Logical value specifying whether to ignore the coverage of descendant objects

1 — Ignore coverage of descendant objects
0 — Collect coverage for descendant objects

object

The object argument specifies an object in the Simulink® model or Stateflow® diagram that receives decision coverage. Valid values for object include the following:

Object SpecificationDescription

BlockPath

Full path to a model or block

BlockHandle

Handle to a model or block

slObj

Handle to a Simulink API object

sfID

Stateflow ID

sfObj

Handle to a Stateflow API object

{BlockPath, sfID}

Cell array with the path to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart

{BlockPath, sfObj}

Cell array with the path to a Stateflow chart or atomic subchart and a Stateflow object API handle contained in that chart or subchart

{BlockHandle, sfID}

Cell array with a handle to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart

When specifying an S-function block, valid values for object include the following:

Object SpecificationDescription

{BlockPath, fName}

Cell array with the path to an S-Function block and the name of a source file.

{BlockHandle, fName}

Cell array with an S-Function block handle and the name of a source file.

{BlockPath, fName, funName}

Cell array with the path to an S-Function block, the name of a source file, and a function name.

{BlockHandle, fName, funName}

Cell array with an S-Function block handle, the name of a source file an a function name.

For coverage data collected during Software-in-the-Loop (SIL) mode or Processor-in-the-Loop (PIL) simulation mode, valid values for object include the following:

Object SpecificationDescription

{fileName, funName}

Cell array with the name of a source file and a function name.

{Model, fileName}

Cell array with a model name (or model handle) and the name of a source file.

{Model, fileName, funName}

Cell array with a model name (or model handle), the name of a source file, and a function name.

mode

The mode argument specifies the simulation mode for coverage. Valid values for mode include the following:

Object SpecificationDescription

'Normal'

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 Software-in-the-Loop (SIL) or Processor-in-the-Loop (PIL) simulation mode.

'ModelRefTopSIL' (or 'ModelRefTopPIL')

Model reference in Software-in-the-Loop (SIL or Processor-in-the-Loop (PIL) simulation mode with code interface set to top model.

Output Arguments

coverage

Two-element vector of the form [covered_outcomes total_outcomes]. coverage is empty if cvdo does not contain modified condition/decision coverage results for object. The two elements are:

covered_outcomesNumber of condition/decision outcomes satisfied for object
total_outcomesTotal number of condition/decision outcomes for object

description

A structure array containing the following fields:

textCharacter vector denoting whether the condition/decision is associated with a block output or Stateflow transition
condition.textCharacter vector describing a condition/decision or the block port to which it applies
condition.achievedLogical array indicating whether a condition case has been fully covered
condition.trueRsltString representing a condition case expression that produces a true result
condition.falseRsltString representing a condition case expression that produces a false result

Examples

Collect MCDC coverage for the slvnvdemo_cv_small_controller model and determine the percentage of MCDC coverage collected for the Logic block in the Gain subsystem:

mdl = 'slvnvdemo_cv_small_controller';
open_system(mdl)
%Create test specification object
testObj = cvtest(mdl)
%Enable MCDC coverage
testObj.settings.mcdc = 1;
%Simulate model
data = cvsim(testObj)
%Retrieve MCDC results for Logic block
blk_handle = get_param([mdl, '/Gain/Logic'], 'Handle');
cov = mcdcinfo(data, blk_handle)
%Percentage of MCDC outcomes covered
percent_cov = 100 * cov(1) / cov(2)

Alternatives

Use the coverage settings to collect MCDC coverage for a model:

  1. Open the model.

  2. In the Model Editor, select Analysis > Coverage > Settings.

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

  4. Under Coverage metrics, select MCDC as the structural coverage level.

  5. On the Coverage > Results pane, specify the output you need.

  6. Click OK to close the Configuration Parameters dialog box and save your changes.

  7. Simulate the model and review the MCDC coverage results.

Introduced in R2006b

Was this topic helpful?