Simulink.sdi.DiffRunResult class

Package: Simulink.sdi

Access run comparison metadata

Description

The Simulink.sdi.DiffRunResult class provides access to the run comparison metadata. You can use the getSignalByIndex method to access the data and comparison results for each signal in the run comparison.

Construction

DiffRunResultObj = Simulink.sdi.compareRuns(runID1, runID2) returns a Simulink.sdi.DiffRunResult object to provide access to the comparison results from comparing the runs corresponding to runID1 and runID2.

Input Arguments

expand all

Numeric run identifier for the Baseline run in the comparison.

Numeric identifier for the Compare to run in the comparison.

Properties

expand all

Version of MATLAB® used.

Run identifier for the Baseline signal of the comparison.

Run identifier for the Compare to signal of the comparison.

Number of signals aligned between the two runs in the comparison. For more information on how signals are aligned for comparisons, see How the Simulation Data Inspector Compares Data.

Date and time the Simulink.sdi.DiffRunResult object was created.

Data Types: datetime

Global tolerance values used for the run comparison. The GlobalTolerance property value is a structure with fields:

  • AbsTol — Global absolute tolerance used for the run comparison.

  • RelTol — Global relative tolerance used for the run comparison.

  • TimeTol — Global time tolerance used for the run comparison.

For more information about how tolerances are used and calculated for comparisons, see How the Simulation Data Inspector Compares Data.

Comparison results summary. The summary is a structure with a field for each possible Status a comparison result signal could have. The value of each field indicates the number of signals in the run comparison with the corresponding Status.

  • WithinTolerance — Signal comparison completed, and all data points compared fell within the specified tolerance.

  • OutOfTolerance — Signal comparison completed, and some data points compared fell outside of the specified tolerance.

  • Unaligned — Signal from the Baseline run did not align with a signal in the Compare to run.

  • Empty — Aligned Baseline or Compare to signal contains no data.

  • EmptySynced — Synchronized Baseline or Compare to signal contains no data.

  • Canceled — Signal result not computed because the user canceled the comparison.

  • Pending — Comparison is in progress and the signal result computation has not started.

  • Processing — Signal result computation in progress.

  • UnitsMismatchBaseline and Compare to signal units do not match.

  • Unsupported — Simulation Data Inspector comparison algorithm does not support this type of signal. For example, signals with data types that lose precision when converted to double are not supported.

For more information about alignment, tolerances, and synchronization, see How the Simulation Data Inspector Compares Data.

Methods

getResultByIndexReturn signal comparison result

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

collapse 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.

Setup

Load the model, and mark the q, rad/sec and alpha, rad signals for logging. Then, simulate the model to create the baseline run.

% Load example model
load_system('slexAircraftExample')

% Mark the q, rad/sec and alpha, rad signals for logging
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',3,'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',4,'on')

% Simulate system
out_1 = sim('slexAircraftExample');

Modify Model Parameter

Modify the model parameter Ts in the model workspace to change the time constant of the input low-pass filter.

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

% Simulate again
out_2 = sim('slexAircraftExample');

Compare Runs and Inspect Results

Use the Simulink.sdi.compareRuns function to compare the data from the simulations. Then, inspect the match property of the signal result to see whether the signals fell within the default tolerance of 0.

% 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
sig1Result1 = getResultByIndex(diffRun1,1);
sig2Result1 = getResultByIndex(diffRun1,2);

% Check whether signals matched
sig1Result1.Status
ans = 
OutOfTolerance
sig2Result1.Status
ans = 
OutOfTolerance

Compare Runs with Signal Tolerances

The signals did not match within the default tolerance of 0. To further analyze the effect of the time constant change, add signal tolerances to the comparison with the baseline signal properties to determine the tolerance required for a pass. This example uses a combination of time and absolute tolerances.

% Get signal object for sigID1
run1 = Simulink.sdi.getRun(runID1);
sigID1 = getSignalIDByIndex(run1,1);
sigID2 = getSignalIDByIndex(run1,2);

sig1 = Simulink.sdi.getSignal(sigID1);
sig2 = Simulink.sdi.getSignal(sigID2);

% Set tolerances for q, rad/sec
sig1.AbsTol = 0.1;
sig1.TimeTol = 0.6;

% Set tolerances for alpha, rad
sig2.AbsTol = 0.2;
sig2.TimeTol = 0.8;

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

% Check the result
sig1Result2.Status
ans = 
WithinTolerance
sig2Result2.Status
ans = 
WithinTolerance

Alternatives

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

Introduced in R2012b