Documentation

Simulink.sdi.DiffSignalResult class

Package: Simulink.sdi

Access signal comparison results

Description

The Simulink.sdi.DiffSignalResult object provides access to the data and metadata created by a signal comparison. A Simulink.sdi.DiffSignalResult object gives access the difference signal, tolerance data, and the synchronized signal data.

Construction

DiffSignalObj = Simulink.sdi.compareSignals(signalID1, signalID2)creates a Simulink.sdi.DiffSignalResult object to provide access to the results of the comparison of the signals corresponding to sigID1 and sigID2.

DiffSignalObj = DiffRunObj.getResultByIndex(index) returns a Simulink.sdi.DiffSignalResult object for the signal comparison corresponding to the index within a Simulink.sdi.DiffRunResult object.

Input Arguments

expand all

Numeric signal identifier for the Baseline signal in comparison.

Numeric signal identifier for the Compare to signal in comparison

Index of the signal within the run.

Properties

expand all

Difference signal resulting from the comparison as a timeseries object.

Logical indicator of whether comparison signals match within the tolerances.

  • 0 indicates that the difference between the signals is not within tolerance.

  • 1 indicates that the difference between the signals is within tolerance.

Logical indicator of whether comparison signals' units match. Comparisons of signals with units that do not match are always marked out of tolerance, and no difference signal is computed.

  • 0 indicates that the signals' units do not match.

  • 1 indicates that the signals' units match.

Maximum difference between the two comparison signals.

Unique signal identifier for the Baseline comparison signal.

Unique signal identifier for the Compare to comparison signal.

Synchronized Baseline signal. For more information about synchronization, see How the Simulation Data Inspector Compares Data.

Synchronized Compare to signal. For more information about synchronization, see How the Simulation Data Inspector Compares Data.

Tolerance data for every data point of the comparison. For more information on how the tolerance signal is computed, see How the Simulation Data Inspector Compares Data.

Copy Semantics

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

Examples

expand all

This example uses the slexAircraftExample model to demonstrate the comparison of a control system's input and output signals. The example marks the signals for streaming then gets the run object for a simulation run. Signal IDs from the run object specify the signals to be compared.

% Load model slexAircraftExample, and mark signals for streaming
load_system('slexAircraftExample')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Pilot', 1, 'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model', 4, 'on')

% Simulate model slexAircraftExample
sim('slexAircraftExample')

% Get run IDs for most recent run
allIDs = Simulink.sdi.getAllRunIDs;
runID = allIDs(end);

%Get Run object
run = Simulink.sdi.getRun(runID);

% Get signal IDs
signalID1 = run.getSignalIDByIndex(1);
signalID2 = run.getSignalIDByIndex(2);

if (run.isValidSignalID(signalID1))
    % Change signal tolerance
    signal1 = Simulink.sdi.getSignal(signalID1);
    signal1.AbsTol = 0.1;
end

if (run.isValidSignalID(signalID1) && run.isValidSignalID(signalID2))
    % Compare signals
    diff = Simulink.sdi.compareSignals(signalID1, signalID2);

    % Check whether signals match within tolerance
    match = diff.match
end
match =

  logical

   0

Alternatives

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

Introduced in R2012b

Was this topic helpful?