How do I automatically export Simulink Test Data from the test manager with a script

조회 수: 12 (최근 30일)
I would like to run tests in the testmanger and export the model outputs so I can parse it and update my baseline spreadsheet with data.
I have tried the script below. but the result of 'getTestCaseResults(tsr)' function does not hold the output data. The only way I can do it right now is righ clicking on the test resulut in the manager and clicking export data.
clear;
sltest.testmanager.clear;
% Define the name of the Simulink model and the test file
modelName = 'brake_control.slx'; % Replace with your model name
testFileName = 'brake_control.mldatx'; % Replace with your test file name
% Load the model
load_system(modelName);
testFile = sltest.testmanager.load(testFileName);
resultsobj = sltest.testmanager.run;
tfr = getTestFileResults(resultsobj);
tsr = getTestSuiteResults(tfr);
tcr = getTestCaseResults(tsr);

답변 (1개)

Altaïr
Altaïr 2025년 4월 15일
편집: Altaïr 2025년 4월 15일
Hey @Kamal,
The signals under the Sim Output section in the Test Manager can be accessed as a Dataset and utilized as needed. Here's a guide on how to achieve this using an example from the documentation, which can be found here:
After running the test file, the Sim Output signals should appear in the test results.
To get the handle to the Sim Output section, which is a Simulink.sdi.Run object, execute the following command:
resultSet = sltest.testmanager.getResultSets;
tfr = resultSet.getTestFileResults;
tsr = tfr.getTestSuiteResults;
tcr = tsr.getTestCaseResults;
simOut = tcr.getOutputRuns
The export method of the simOut object can then be used to export the signal to the base workspace or a file. For more information, refer to the following link:

카테고리

Help CenterFile Exchange에서 Test Scripts에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by