Documentation

Contents

Simulink.sdi.DiffRunResult class

Package: Simulink.sdi

Results from comparing two simulation runs

Description

The Simulink.sdi.DiffRunResult class manages the results from comparing two simulation runs. A Simulink.sdi.DiffRunResult object contains a Simulink.sdi.DiffSignalResult object for each signal compared.

Construction

The function Simulink.sdi.compareRuns returns a handle to a Simulink.sdi.DiffRunResult object.

Properties

runID1

Run ID, a unique number identifying the first run compared.

runID2

Run ID, a unique number identifying the second run compared.

count

Number of compared signal results.

matlabVersion

Version of MATLAB used to create an instance of Simulink.sdi.DiffRunResult.

dateCreated

Date of object creation, stored in serial date number format.

Methods

getResultByIndexReturn signal comparison result, Simulink.sdi.DiffSignalResult object

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB® documentation.

Examples

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 "slexAircraftExample" for logging and simulate
set_param('slexAircraftExample/Pilot','WaveForm','square');
simOut = sim('slexAircraftExample', '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('slexAircraftExample/Pilot','WaveForm','sawtooth');
simOut = sim('slexAircraftExample', 'SaveOutput','on', ...
             'SaveFormat', 'StructureWithTime', ...
             'ReturnWorkspaceOutputs', 'on');
      
% Create another Simulation Data Inspector run
runID2 = Simulink.sdi.createRun('Second Run','namevalue',{'simOut'},{simOut});

% Compare two runs and get an instance of Simulink.sdi.DiffRunResult
diff = Simulink.sdi.compareRuns(runID1, runID2);

% Get the number of signal comparison results
count = diff.count;

% Iterate over results and find out if signals match
for i=1:count
   % Get the Simulink.sdi.DiffSignalResult, diffSignal
		diffSignal = diff.getResultByIndex(i);
		signalID1  = diffSignal.signalID1;
   signalID2  = diffSignal.signalID2;
   match      = diffSignal.match;

   if match
      disp([num2str(signalID1) ' and ' num2str(signalID2)...
           ' match']);
   else
      disp([num2str(signalID1) ' and ' num2str(signalID2)...
           ' don''t match']);
   end
end
Was this topic helpful?