Main Content

本页采用了机器翻译。点击此处可查看英文原文。

getSimulationPlots

类: sltest.testmanager.TestIterationResult
命名空间: sltest.testmanager

从回调中获取图

语法

figs = getSimulationPlots(result)
figs = getSimulationPlots(result,index)

说明

figs = getSimulationPlots(result) 返回与结果相关的测试迭代的回调生成的图的图形句柄。使用此方法返回的数字不可见。要查看图表,请将图形句柄 Visible 属性设置为 'on'

figs = getSimulationPlots(result,index) 返回由 index 指定的仿真的图形句柄。

输入参数

全部展开

测试用例迭代结果获取回调图形句柄,指定为 sltest.testmanager.TestIterationResult 对象或结果的仿真索引。

仿真索引,指定为 12

输出参量

全部展开

来自指定迭代的测试用例回调的图形,以图形句柄数组的形式返回。

示例

全部展开

% Open the model for this example
openExample('sldemo_absbrake');

% Create the test file, suite, and case
tf = sltest.testmanager.TestFile...
   ('Simulation Plots for Test Iterations');
ts = createTestSuite(tf,'Sim Plots Test Suite');
tc = createTestCase(ts,'baseline','Sim Plots Test Case');

% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

% Create a plot in a callback
setProperty(tc,'PostloadCallback',...
   'a = [1,2,3]; f = figure; plot(a);');

% Set option to save figures
opt = getOptions(tf);
opt.SaveFigures = true;

% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');

% Define iterations
vars = 32 : 0.5 : 34;

for k = 1 : length(vars)

    % Create test iteration object
    testItr = sltest.testmanager.TestIteration;

    % Set the parameter value for this iteration
    setVariable(testItr,'Name','g','Source',...
       'base workspace','Value',vars(k));

    str = sprintf('Iteration %d',k);

    % Add the iteration object to the test case
    addIteration(tc,testItr,str);
end

% Run the test and capture results
resultset = run(tf);
tfr = getTestFileResults(resultset);
tsr = getTestSuiteResults(tfr);
tcr = getTestCaseResults(tsr);
tir = getIterationResults(tcr);

% Get the callback plot figure handles from the first iteration
figs = tir(1).getSimulationPlots;

版本历史记录

在 R2017a 中推出