How to access streamed signals for custom criteria in Simulink Test?

1 次查看(过去 30 天)
I would like to access streamed signals (as for Simulation Data Inspector) for custom criteria in Simulink Test. I can find the streamed signals in the results view but cannot find them in the test-object, where all other information about the test is stored. I wondered if thre is a way Simulink Test stores the streamed signals in this object too?
Kind regards

回答(1 个)

Abhishek
Abhishek 2017-4-12
编辑:Abhishek 2017-4-12
I assume you are using R2016b or earlier when streamed and logged signals were handled differently. You can use the following code in custom criteria to get all the signals in simulation output (including streamed signals).
% Get the output Simulink.sdi.Run object corresponding to the simulation output.
% For equivalence tests, it will be an array of two objects
outputRun = test.TestResult.getOutputRuns;
% get the number of signals in the simulation run
numSigs = outputRun.SignalCount;
% iterate over all signals to get signal data and metadata
for i = 1:numSigs
% this will return an object of type Simulink.sdi.Signal
sig = outputRun.getSignalByIndex(i);
% this will return a struct containing data and time
dataAndTime = sig.dataValues;
end

产品

Community Treasure Hunt

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

Start Hunting!

Translated by