getSimulationPlots
类: sltest.testmanager.TestCaseResult
命名空间: sltest.testmanager
从测试用例回调中获取图
语法
figs = getSimulationPlots(result)
figs = getSimulationPlots(result,index)
说明
输入参数
输出参量
示例
获取图形句柄并从测试用例结果生成图
获取图形句柄。
% Open the model for this example openExample('sldemo_absbrake'); % Create the test file, suite, and case tf = sltest.testmanager.TestFile('Simulation Plots Test Case'); 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 test case 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'); % Run the test and capture results resultset = run(tf); tfr = getTestFileResults(resultset); tsr = getTestSuiteResults(tfr); tcr = getTestCaseResults(tsr); % Get the test case callback plots figure handles figs = tcr.getSimulationPlots;
绘制图形。
将
callbackfn(sltest_simout)添加到测试用例清理回调。setProperty(tc,'CleanupCallback','callbackfn(sltest_simout)');
在名为
simout的 MATLAB® 文件中创建simout.m函数。该函数从仿真对象获取第一个信号,打开一个图形,并在该图形中绘制时间与数据的关系。function callbackfn(simout) sig1 = simout.logsout.get(1); figure; plot(sig1.Values.Time, sig1.Values.Data) end使用此代码查看仿真图。代码运行测试用例,获取测试用例结果和图形,并将第一个图形设置为可见。
rs = tc.run tcr = rs.getTestCaseResults figs = getSimulationPlots(tcr) figs(1).set('Visible','on')
版本历史记录
在 R2017a 中推出