Main Content

cvsim

Simulate and return model coverage results for test objects

Description

cvdo= cvsim(modelName)simulates the model and returns the coverage results in thecvdataobject,cvdo.

cvdo= cvsim(testObj)simulates the model and returns the coverage results for thecvtestobject,testObj.

[cvdo,simOut] = cvsim(__,Name,Value)specifies the model parameters, simulates the model, and returns the coverage results in thecvdataobject,cvdo, and the simulation outputs in theSimulink.SimulationOutputobject,simOut.

Note

cvsimignores model parameters listed in theCoveragepane of the Configuration Parameters window. Create acvtestobject to set coverage options, or usesiminstead.

[cvdo,simOut] = cvsim(testObj,paramStruct)sets the model parameters specified in a structureparamStruct.

example

[cvdo1,...,cvdoN] = cvsim(testObj1,...,testObjN)simulates the model forN测试对象,并返回的结果报道each object.

Note

cvsimwill record coverage even if coverage is not enabled in the model parameters.

Examples

collapse all

This example shows how to usecvsimwith acvtestobject input and a structure of model parameters.

Load theslvnvdemo_cv_small_controllerexample model.

modelName ='slvnvdemo_cv_small_controller'; load_system(modelName)

Create acvtestobject and turn on decision coverage.

testObj = cvtest(modelName); testObj.settings.decision = 1;

Create a structure that defines the following model parameters:

  • Set the absolute tolerance,AbsTol, to1e-5.

  • Enable the simulation to save states to the workspace withSaveState.

  • Declare the variable name to save the state information in withSaveStateName.

  • Enable Simulink® to save simulation output data to the workspace withSaveOutput.

  • Declare the variable name in which to store the simulation output data withOutputSaveName.

paramStruct.AbsTol ='1e-5'; paramStruct.SaveState ='on'; paramStruct.StateSaveName ='xoutNew'; paramStruct.SaveOutput ='on'; paramStruct.OutputSaveName ='youtNew';

Simulate the model withcvsimand generate a coverage report withcvhtml.

[covData,simOut] = cvsim(testObj,paramStruct); cvhtml('CoverageReport.html',covData,'-sRT=0');

Input Arguments

collapse all

Name of a Simulink Model, specified as a character array or string array.cvsimsimulates the model with the current coverage settings.

Data Types:char|string

Coverage test settings, specified as acvtestobject.cvsimcollects coverage using the settings specified intestObj.

Data Types:cvtest

Model parameters, specified as a structure. You can specify model parameters as a structure and use the structure instead of name-value pair arguments to set multiple parameters.

paramStructfields are the names of model parameters and the values are the corresponding parameter values.

Example:paramStruct.AbsTol = '1e-5';

Data Types:struct

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

Example:[cvdo,simOut] = cvsim(testObj,'AbsTol','1e-5');specifies that the model is simulated using an absolute tolerance of1e-5with coverage settings specified intestObj.

cvsimsupports all model parameters that are supported bysim, except for parameters in theCoveragepane of the Configuration Parameters window.

Name of a model parameter, specified as a character array or string array. The value of the parameter is specified as the next argument.

Data Types:char|string

Output Arguments

collapse all

cvdo,返回as acvdataobject. When recording coverage for multiple models in a hierarchy,cvdois acv.cvdatagroupobject instead.cvdocontains the coverage data from the simulated system.

SeeEvaluate Coverage Resultsfor a list ofinfofunctions.

Seecvdata Propertiesfor the object structure.

simOut,返回as aSimulink.SimulationOutputobject.

Introduced before R2006a