Documentation

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 runs. A Simulink.sdi.DiffRunResult object contains a Simulink.sdi.DiffSignalResult object for each signal compared.

Construction

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

Properties

expand all

Number of compared signal results, stored as an integer.

Date of at time of object creation, stored as a datetime object.

Example:

Version of MATLAB used to create an instance of Simulink.sdi.DiffRunResult, stored as a character vector.

Example:

Run ID, a unique number identifying the first run compared, stored as a character vector.

Run ID, a unique number identifying the second run compared, stored as a character vector.

Methods

getResultByIndexReturn signal comparison result

Examples

expand all

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)...
           ' do not match']);
   end
end

Related Examples

Introduced in R2012b

Was this topic helpful?