|
|
|
| R2012a Documentation → Simulink Verification and Validation | |
Learn more about Simulink Verification and Validation |
|
| Contents | Index |
cvsave(filename, model)
cvsave(filename, cvto1, cvto2,
...)
cvsave(filename, cell_array{
:})
cvsave(filename, model) saves all the tests (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(filename, cvto1, cvto2, ...) saves multiple cvtest objects in the text file filename.cvt. cvsave also saves information about any referenced models.
cvsave(filename, cell_array{ :}) saves the test results stored in each element of cell_array to the file filename.cvt. Each element in cell_array contains test results for a cvdata object.
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{ :});
To save cumulative coverage results:
In the Model Editor, select Tools > Coverage Settings.
On the Results tab:
Select Save cumulative results in workspace variable.
Select Save last run in workspace variable.
Click OK to close the Coverage Settings dialog box.
Simulate the model.

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |