| Contents | Index |
diff = Simulink.sdi.compareRuns(runID1,runID2)
diff = Simulink.sdi.compareRuns(runID1,runID2) compares the matched signals between two simulation runs and returns their differences in a Simulink.sdi.DiffRunResult object.
runID1 |
Run ID, a unique number identifying the first run for comparison. |
runID2 |
Run ID, a unique number identifying the second run for comparison. |
diff |
Instance of Simulink.sdi.DiffRunResult that describes the difference between two simulation runs. |
The function Simulink.sdi.compareRuns returns a Simulink.sdi.DiffRunResult object containing the results of the comparison. The Simulink.sdi.DiffRunResult object contains a Simulink.sdi.DiffSignalResult object for each signal comparison between the two simulation runs.
% Configure model "sldemo_f14" for logging and simulate
set_param('sldemo_f14/Pilot','WaveForm','square');
simOut = sim('sldemo_f14', 'SaveOutput','on', ...
'SaveFormat', 'StructureWithTime', ...
'ReturnWorkspaceOutputs', 'on');
% Create a Simulation Data Inspector run, Simulink.sdi.Run, from simOut in the base workspace
runID1 = Simulink.sdi.createRun('First Run','namevalue',{'simOut'},{simOut});
% Simulate again
set_param('sldemo_f14/Pilot','WaveForm','sawtooth');
simOut = sim('sldemo_f14', 'SaveOutput','on', ...
'SaveFormat', 'StructureWithTime', ...
'ReturnWorkspaceOutputs', 'on');
% Create another Simulation Data Inspector run
runID2 = Simulink.sdi.createRun('Second Run','namevalue',{'simOut'},{simOut});
% Compare two runs
difference = Simulink.sdi.compareRuns(runID1, runID2);
% Number of comparisons in result
numComparisons = difference.count;
% Iterate through each result element
for i = 1:numComparisons
% Get signal result at index i
signalResult = difference.getResultByIndex(i);
% Get signal IDs for each comparison result
sig1 = signalResult.signalID1;
sig2 = signalResult.signalID2;
% Display if signals match or not
displayStr = 'Signals with IDs %d and %d %s \n';
if signalResult.match
fprintf(displayStr, sig1, sig2, 'match');
else
fprintf(displayStr, sig1, sig2, 'do not match');
end
endSimulink.sdi.createRun | Simulink.sdi.DiffRunResult

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |