Save coverage tests and results to file
cvsave(filename, model)
cvsave(filename, cvd)
cvsave(filename, cvto1, cvto2,
...)
cvsave(filename, cell_array{
:})
cvsave(
saves all the tests (filename
, model
)cvtest
objects)
and results (cvdata
objects) related to model
in
the text file filename.cvt
. model
is
a handle to or name of a Simulink® model.
cvsave(
saves all the results (filename
, cvd
)cvdata
objects)
for the active model in the text file filename.cvt
. cvsave
also
saves information about any referenced
models.
cvsave(filename,
saves multiple cvto
1, cvto
2,
...)cvtest
objects
in the text file filename.cvt
. cvsave
also
saves information about any referenced
models.
cvsave(
saves the test results stored in each element of filename
, cell_array
{
:})cell_array
to
the file filename.cvt
. Each element in cell_array
contains
test results for a cvdata
object.
|
Character vector or string containing the name of the file in which to
save the data. |
|
Handle to a Simulink model |
|
|
|
|
|
Cell array of |
Save coverage results for the slvnvdemo_cv_small_controller
model
in ratelim_testdata.cvt
:
model = 'slvnvdemo_cv_small_controller'; open_system(model); cvt = cvtest(model); cvd = cvsim(cvt); cvsave('ratelim_testdata', model);
Save cumulative coverage results for the Adjustable Rate Limiter
subsystem in the slvnvdemo_ratelim_harness
model
from two simulations:
% Open model and subsystem mdl = 'slvnvdemo_ratelim_harness'; mdl_subsys = ... 'slvnvdemo_ratelim_harness/Adjustable Rate Limiter'; open_system(mdl); open_system(mdl_subsys); % Create data files t_gain = (0:0.02:2.0)'; u_gain = sin(2*pi*t_gain); t_pos = [0;2]; u_pos = [1;1]; t_neg = [0;2]; u_neg = [-1;-1]; save('within_lim.mat','t_gain','u_gain','t_pos','u_pos', ... 't_neg', 'u_neg'); t_gain = [0;2]; u_gain = [0;4]; t_pos = [0;1;1;2]; u_pos = [1;1;5;5]*0.02; t_neg = [0;2]; u_neg = [0;0]; save('rising_gain.mat','t_gain','u_gain','t_pos','u_pos', ... 't_neg', 'u_neg'); % Specify coverage options in cvtest object testObj1 = cvtest(mdl_subsys); testObj1.label = 'Gain within slew limits'; testObj1.setupCmd = 'load(''within_lim.mat'');'; testObj1.settings.mcdc = 1; testObj1.settings.condition = 1; testObj1.settings.decision = 1; testObj2 = cvtest(mdl_subsys); testObj2.label = ... 'Rising gain that temporarily exceeds slew limit'; testObj2.setupCmd = 'load(''rising_gain.mat'');'; testObj2.settings.mcdc = 1; testObj2.settings.condition = 1; testObj2.settings.decision = 1; % Simulate the model with both cvtest objects [dataObj1,simOut1] = cvsim(testObj1); [dataObj2,simOut2] = cvsim(testObj2,[0 2]); cumulative = dataObj1+dataObj2; cvsave('ratelim_testdata',cumulative);
As in the preceding example, save cumulative coverage results
for the Adjustable Rate Limiter subsystem in the slvnvdemo_ratelim_harness
model
from two simulations. Save the results in a cell array and then save
the data to a file:
% Open model and subsystem mdl = 'slvnvdemo_ratelim_harness'; mdl_subsys = ... 'slvnvdemo_ratelim_harness/Adjustable Rate Limiter'; open_system(mdl); open_system(mdl_subsys); % Create data files t_gain = (0:0.02:2.0)'; u_gain = sin(2*pi*t_gain); t_pos = [0;2]; u_pos = [1;1]; t_neg = [0;2]; u_neg = [-1;-1]; save('within_lim.mat','t_gain','u_gain','t_pos','u_pos', ... 't_neg', 'u_neg'); t_gain = [0;2]; u_gain = [0;4]; t_pos = [0;1;1;2]; u_pos = [1;1;5;5]*0.02; t_neg = [0;2]; u_neg = [0;0]; save('rising_gain.mat','t_gain','u_gain','t_pos','u_pos', ... 't_neg', 'u_neg'); % Specify coverage options in cvtest object testObj1 = cvtest(mdl_subsys); testObj1.label = 'Gain within slew limits'; testObj1.setupCmd = 'load(''within_lim.mat'');'; testObj1.settings.mcdc = 1; testObj1.settings.condition = 1; testObj1.settings.decision = 1; testObj2 = cvtest(mdl_subsys); testObj2.label = ... 'Rising gain that temporarily exceeds slew limit'; testObj2.setupCmd = 'load(''rising_gain.mat'');'; testObj2.settings.mcdc = 1; testObj2.settings.condition = 1; testObj2.settings.decision = 1; % Simulate the model with both cvtest objects [dataObj1,simOut1] = cvsim(testObj1); [dataObj2,simOut2] = cvsim(testObj2,[0 2]); % Save the results in the cell array cov_results{1} = dataObj1; cov_results{2} = dataObj2; % Save the results to a file cvsave('ratelim_testdata', cov_results{ :});
Use the coverage settings to save cumulative coverage results for a model:
Open the model for which you want to save cumulative coverage results.
In the Model Editor, select Model Settings on the Modeling tab.
On the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.
On the Coverage > Results pane, select Save last run in workspace variable.
Click OK to close the Configuration Parameters dialog box and save your changes.
Simulate the model and review the results.