Documentation

getResultByIndex

Class: Simulink.sdi.DiffRunResult
Package: Simulink.sdi

Return signal comparison result

Syntax

diffSigObj = diffRunObj.getResultByIndex(index)

Description

diffSigObj = diffRunObj.getResultByIndex(index) returns the Simulink.sdi.DiffSignalResult object diffSigObj corresponding to the index in the Simulink.sdi.DiffRunResult object, diffRunObj.

Input Arguments

expand all

Index of the signal in the Simulink.sdi.DiffRunResult object.

Output Arguments

expand all

Simulink.sdi.DiffSignalResult object for the signal at the specified index.

Examples

expand all

You can change tolerance values on a signal-by-signal basis to evaluate the effect of a model parameter change. This example uses the slexAircraftExample model and the Simulation Data Inspector to evaluate the effect of changing the time constant for the low-pass filter following the control input.

% Load example model
load_system('slexAircraftExample')

% Mark the alpha, rad signal for streaming
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model', 4, 'on')

% Simulate system
sim('slexAircraftExample')

% Change input filter time constant
modelWorkspace = get_param('slexAircraftExample', 'modelworkspace');
modelWorkspace.assignin('Ts', 0.2)

% Simulate again
sim('slexAircraftExample')

% Get run data
runIDs = Simulink.sdi.getAllRunIDs;
runID1 = runIDs(end - 1);
runID2 = runIDs(end);

% Compare runs
diffRun1 = Simulink.sdi.compareRuns(runID1, runID2);

% Get signal result
sigResult1 = diffRun1.getResultByIndex(1);

% Check whether signals matched
sigResult1.match
ans =

  logical

   0

% Get signal object for sigID1
run1 = Simulink.sdi.getRun(runID1);
sigID1 = run1.getSignalIDByIndex(1);
sig1 = Simulink.sdi.getSignal(sigID1);

% Change absolute tolerance to 0.2
sig1.absTol = 0.2;

% Run the comparison again
diffRun2 = Simulink.sdi.compareRuns(runID1, runID2);
sigResult2 = diffRun2.getResultByIndex(1);

% Check the result
sigResult2.match
ans =

  logical

   1

Alternatives

You can inspect comparison results using the Simulation Data Inspector UI. For more information, see Compare Simulation Data.

Introduced in R2012b

Was this topic helpful?