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

2 views (last 30 days)
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

Answers (1)

Abhishek
Abhishek on 12 Apr 2017
Edited: Abhishek on 12 Apr 2017
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

Products

Community Treasure Hunt

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

Start Hunting!