Main Content

sldvruntest

Simulate model by using input data

Description

outData = sldvruntest(model, dataFile) simulates the model by using all the test cases in the dataFile. outData is an array of Simulink.SimulationOutput objects. Each array element contains the simulation output data of the corresponding test case.

outData = sldvruntest(model, dataFile, runOpts) simulates the model by using all the test cases in the dataFile. runOpts defines the options for simulating the test cases.

example

[outData, covData] = sldvruntest(model, dataFile, runOpts) simulates the model by using the test cases in the dataFile. When the runOpts field coverageEnabled is true, the Simulink® Coverage™ software collects the model coverage information during the simulation. sldvruntest returns the coverage data in the cvdata object covData.

Examples

collapse all

Analyze the sldvdemo_cruise_control model. Simulate the model by using the data from the three test cases. Examine the signal logging data by using the Simulation Data Inspector.

Open the sldvdemo_cruise_control example model.

openExample('sldv/CruiseControlTestGenerationExample',...
'supportingFile', 'sldvdemo_cruise_control');

Set the sldvoptions and analyze the model.

opts = sldvoptions;
opts.Mode = 'TestGeneration';
opts.SaveHarnessModel = 'on';
opts.SaveReport = 'off';
[ status, files ] = sldvrun('sldvdemo_cruise_control', opts);

Simulate the model by using the data from the three test cases. Examine the signal logging data by using the Simulation Data Inspector.

runOpts = sldvruntestopts;
[ outData ] = sldvruntest('sldvdemo_cruise_control',...
    files.DataFile, runOpts);
Simulink.sdi.createRun('Test Case 1 Output', 'namevalue',...
    {'output'}, {outData(1).find('logsout_sldvruntest')});
Simulink.sdi.createRun('Test Case 2 Output', 'namevalue',...
    {'output'}, {outData(2).find('logsout_sldvruntest')});
Simulink.sdi.createRun('Test Case 3 Output', 'namevalue',...
    {'output'}, {outData(3).find('logsout_sldvruntest')});
Simulink.sdi.view;

Generate coverage report by simulating the test cases for the sldvdemo_cruise_control model.

Open the sldvdemo_cruise_control example model.

openExample('sldv/CruiseControlTestGenerationExample',...
'supportingFile', 'sldvdemo_cruise_control');

Set the sldvoptions and analyze the model.

opts = sldvoptions;
opts.Mode = 'TestGeneration';
opts.SaveHarnessModel = 'on';
opts.SaveReport = 'off';
[ status, files ] = sldvrun('sldvdemo_cruise_control', opts);

Enable the option to collect model coverage data and simulate the model by using the data. Then, generate coverage report by using cvhtml (Simulink Coverage).

runOpts = sldvruntestopts;
runOpts.coverageEnabled = true; 
[ outData,covData ] = sldvruntest('sldvdemo_cruise_control',...
                      files.DataFile,runOpts); 
cvhtml('coverageReport',covData); 

Input Arguments

collapse all

Name or handle of the Simulink model to simulate, specified as a character vector or string scalar.

Name of the data file, structure, or a spreadsheet that contains the input data, specified as a character vector or string scalar.

For a MAT-file, you can generate the data file by using the Simulink Design Verifier™ analysis or by running the sldvlogsignals function. For more information, see Manage Simulink Design Verifier Data Files.

For a spreadsheet, you can generate the data file by using the Simulink Design Verifier analysis or by running the sldvgenspreadsheet function.

Configurations for sldvruntest, returned as a structure with these fields:

FieldDescription

testIdx

Test case index array to simulate from dataFile. If testIdx is [], sldvruntest simulates all the test cases.

Default: []

signalLoggingSaveFormat

Specify the format for signal logging data for signals that connect to the outport of the model and for intermediate signals that are configured for logging.

If you specify Dataset, data is stored in the Simulink.SimulationData.Dataset objects.

Default: 'Dataset'

coverageEnabled

If true, specifies that the Simulink Coverage software collects the model coverage data during simulation.

Default: false

coverageSetting

cvtest object for collecting the model coverage. If [], sldvruntest uses the existing coverage settings for model.

Default: []

fastRestart

If true, Simulink Design Verifier uses fast restart mode for model simulation.

Default: true

useParallel

If true, Simulink Design Verifier simulates test cases with parallel computing. This option requires a Parallel Computing Toolbox™ license.

Default: false

Note

runOpts = sldvruntestopts returns a runOpts structure with the default values for each field.

Output Arguments

collapse all

Output data for simulated test cases, returned as an array of Simulink.SimulationOutput object. Each Simulink.SimulationOutput object has these fields:

Field NameDescription

tout_sldvruntest

Simulation time

xout_sldvruntest

State data

yout_sldvruntest

Output signal data

logsout_sldvruntest

Signal logging data for:

  • Signals connected to outports

  • Signals that are configured for logging on the model

Model coverage data, returned as a covdata object.

Note

covdata might reference a file containing the coverage results. The coverage data from the referenced file is automatically loaded into memory when covdata is used by a coverage function. This file gets stored in the sldv_covoutput folder generated within sldv_output folder.

Tips

  • The dataFile that you create with a Simulink Design Verifier analysis or by running sldvlogsignals contains time values and data values. When you simulate a model by using these test cases, you can achieve missing coverage. The missing coverage occurs when the time values in the dataFile are not aligned with the current simulation time step due to numeric calculation differences. You achieve missing coverage more frequently with multirate models— models that have multiple sample times.

  • For useParallel, the following points must be considered when simulating test cases using parallel computing:

    • Starting a parallel pool can take time, which impacts the overall analysis time. To reduce the analysis time:

      • Make sure that the parallel pool is already running before you run a test generation analysis. By default, the parallel pool shuts down after being idle for a specified number of minutes. To change the setting, see the topic 'Specify Your Parallel Preferences' in Parallel Computing Toolbox.

      • Load Simulink on all the parallel pool workers.

    • The simulation occurs sequentially when:

      • The cluster is not local. Configure parallel preferences to use the local cluster only. To change the setting, see the topic 'Specify Your Parallel Preferences' in Parallel Computing Toolbox.

      • The model is in dirty state prior to launching the SLDV analysis.

      • The model has ToFile blocks.

      • The model is in Software-in-the-loop (SIL) simulation mode.

      • The model is an internal harness.

Version History

Introduced in R2007b