Main Content

cvsave

Save coverage settings and results to file

    Description

    cvsave(文件名,model)saves all the coverage settings and results related tomodelin the file文件名.

    cvsave(文件名,covData)saves all the coverage settings and results contained in thecvdataobjectcovData.

    cvsave(文件名,covSettings1,...,covSettingsN)saves multiplecvtestobjects and information about any referenced models.

    Examples

    collapse all

    This example shows how to save coverage data to a file.

    Start by loading the model into memory.

    modelName ='slvnvdemo_cv_small_controller'; load_system(modelName);

    Simulate the model with the coverage settings that are saved with the model.

    covData = cvsim(modelName);

    拯救一个覆盖率数据file calledcoverage_data, containing the coverage data in thecvdataobjectcovData.

    cvsave('coverage_data',covData);

    这个例子展示了如何拯救不止一个封面age data object to a single coverage data file.

    Load the Model

    Load the model into memory.

    modelName ='slvnvdemo_ratelim_harness'; load_system(modelName);

    Set Model Parameters for Coverage

    Create aSimulink.SimulationInputobject to set coverage parameters.

    covSet = Simulink.SimulationInput(modelName); covSet = covSet.setModelParameter('CovEnable','on'); covSet = covSet.setModelParameter('CovMetricStructuralLevel','MCDC'); covSet = covSet.setModelParameter('CovScope','Subsystem'); covSet = covSet.setModelParameter('CovPath','/Adjustable Rate Limiter'); covSet = covSet.setModelParameter('CovSaveSingleToWorkspaceVar','on');

    Simulate the Model to Collect Coverage Data

    Load the data files and then simulate the model to collect two sets of coverage data.

    loadwithin_lim.matcovSet = covSet.setModelParameter('CovSaveName','covData1'); simOut1 = sim(covSet);

    Simulate the model a second time using the second data file.

    loadrising_gain.matcovSet = covSet.setModelParameter('CovSaveName','covData2'); simOut2 = sim(covSet);

    Save the Coverage Data to a File

    Save the results in a cell array.

    cov_results{1} = covData1; cov_results{2} = covData2
    cov_results = 1x2 cell array {1x1 cvdata} {1x1 cvdata}

    Save the results to a file.

    cvsave('ratelim_testdata',cov_results{:});

    Input Arguments

    collapse all

    Name of coverage data file, specified as a character array or a string array.cvsaveappends the extension.cvtto the name of the file when saving it.

    Example:'myCoverageDataFile'

    Data Types:char|string

    Simulink model that has coverage data, specified as a character array or a string array.modelcan be the name of a model or a handle to a model.

    Example:'mySimulinkModel'

    Data Types:char|string

    Coverage settings, specified as acvtestobject, or a cell array ofcvtestobjects.

    Data Types:cvtest|cell

    Coverage data, specified as acvdataobject or a cell array ofcvdataobjects.

    Data Types:cvdata|cell

    Alternatives

    You can save coverage results to a MATLAB workspace variable when you run your model in Simulink:

    1. Open the model for which you want to save cumulative coverage results.

    2. On theModeling tab, selectModel Settings.

    3. In the left pane of the Configuration Parameters dialog box, selectCoverage.

    4. SelectEnable coverage analysis.

    5. In theResultssection, selectSave last run in workspace variable.

    6. ClickOKto close the Configuration Parameters dialog box and save your changes.

    7. Simulate the model by clicking theRunbutton and review the results.

    Version History

    Introduced before R2006a