Access signal comparison results
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.
DiffSignalObj = Simulink.sdi.compareSignals(
Simulink.sdi.DiffSignalResult object to provide access to the
results of the comparison of the signals corresponding to
DiffSignalObj = DiffRunObj.getResultByIndex(
Simulink.sdi.DiffSignalResult object for the signal
comparison corresponding to the
index within a
signalID1— Signal identifier for Baseline signal
Numeric signal identifier for the Baseline signal in comparison.
signalID2— Signal identfier for Compare to signal
Numeric signal identifier for the Compare to signal in comparison
index— Index of signal in run
Index of the signal within the run.
Diff— Difference signal
Difference signal resulting from the comparison as a
Match— Logical indicator of signal match
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.
UnitsMatch— Logical indicator of unit match
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
1 indicates that the signals' units
MaxDifference— Maximum difference
Maximum difference between the two comparison signals.
SignalID1— Baseline signal identifier
Unique signal identifier for the Baseline comparison signal.
SignalID2— Compare to signal identifier
Unique signal identifier for the Compare to comparison signal.
Sync1— Synchronized Baseline signal
Synchronized Baseline signal. For more information about synchronization, see How the Simulation Data Inspector Compares Data.
Sync2— Synchronized Compare to signal
Synchronized Compare to signal. For more information about synchronization, see How the Simulation Data Inspector Compares Data.
Tol— Tolerance signal
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.
Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).
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
You can view and inspect comparison results using the Simulation Data Inspector UI. For more information, see Compare Simulation Data.