Simulink.sdi.DiffSignalResult
Access signal comparison results
Description
When you compare runs or signals using the Simulation Data
Inspector, the results are returned as either a
Simulink.sdi.DiffSignalResult
object or a
Simulink.sdi.DiffRunResult
object that contains one or more
Simulink.sdi.DiffSignalResult
objects. The
DiffSignalResult
object contains the data and metadata for signal
comparison results, such as the difference signal, tolerance data, and the synchronized
signal data.
Creation
When you use the Simulation Data Inspector to compare runs or signals, you can access
signal comparison results in a Simulink.sdi.DiffSignalResult
object two ways:
By using the
Simulink.sdi.compareSignals
function to compare signals.By using the
getResultByIndex
function to accessDiffSignalResult
objects inSimulink.sdi.DiffRunResult
objects.
Properties
Name
— Baseline signal name
character vector
This property is read-only.
Baseline signal name, returned as a character vector. When comparison
results are complex, the name of the DiffSignalResult
object that contains the real data is appended with
(real)
, and the name of the
DiffSignalResult
object that contains the imaginary
data is appended with (imag)
.
Status
— Comparison result signal status
WithinTolerance
| OutOfTolerance
| Unaligned
| Pending
| Processing
| ...
This property is read-only.
Status of the signal comparison corresponding to the
DiffSignalResult
object, returned as one of the following
options. The status can indicate where a given signal comparison is in the
comparison process during a long comparison, or it can indicate information
about the result of the signal comparison.
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 run to compare.Empty
— Aligned signal in the baseline run or run to compare contains no data.EmptySynced
— Synchronized signal in the baseline run or run to compare contains no data. An empty synchronized signal can mean that the signals do not overlap or, if you specified theintersection
synchronization method, that they included none of the same time points.Canceled
— Signal result not computed because the user canceled the comparison or the algorithm ended the comparison before computing this signal result.Pending
— Comparison is in progress and the signal result computation has not started.Processing
— Signal result computation in progress.UnitsMismatch
— The signal units in the baseline run and run to compare do not match.DataTypeMismatch
— The signal data types in the baseline run and run to compare do not match. Only results of comparisons configured to check signal data types can have this status.TimeMismatch
— The signal time vectors in the baseline run and run to compare do not match. Only results of comparisons configured to check signal time vectors can have this status.StartStopMismatch
— The signal start and stop times in the baseline run and run to compare do not match. Only results of comparisons configured to check signal start and stop times can have this status.Unsupported
— The Simulation Data Inspector comparison algorithm does not support this type of signal. For example, signals with data types that lose precision when converted todouble
are not supported.
For more information about alignment, tolerances, and synchronization, see
How the Simulation Data Inspector Compares Data. For more information about
configuring comparisons to check for additional metadata, see Simulink.sdi.compareRuns
.
AlignBy
— Property by which signals aligned for comparison
character vector
This property is read-only.
Property by which signals aligned in a run comparison, returned as a
character vector. When the DiffSignalResult
object was
created from a signal comparison, the AlignBy
property is
empty. For more information about how run comparisons align signals, see
How the Simulation Data Inspector Compares Data.
SignalID1
— Baseline signal ID
integer
This property is read-only.
Unique signal identifier for the baseline signal in the comparison, returned as an integer.
SignalID2
— Signal ID of the signal to compare
integer
This property is read-only.
Unique signal identifier for the signal to compare against the baseline signal, returned as an integer.
MaxDifference
— Maximum difference
double
This property is read-only.
Maximum difference between the two comparison signals, returned as a double.
Sync1
— Synchronized Baseline signal
timeseries
This property is read-only.
Synchronized baseline signal, returned as a timeseries
object. For
more information about synchronization, see How the Simulation Data Inspector Compares Data.
Sync2
— Synchronized Compare to signal
timeseries
This property is read-only.
Synchronized signal to compare, returned as a timeseries
object. For
more information about synchronization, see How the Simulation Data Inspector Compares Data.
Diff
— Difference signal
timeseries
This property is read-only.
Difference signal resulting from the comparison, returned as a timeseries
object.
Examples
Compare Two Signals in the Same Run
You can use the Simulation Data Inspector programmatic interface to compare signals within a single run. This example compares the input and output signals of an aircraft longitudinal flight controller.
Load the Simulation Data Inspector session file that contains the flight control data.
Simulink.sdi.load("AircraftExample.mldatx");
To access the latest run, use the Simulink.sdi.Run.getLatest
function.
aircraftRun = Simulink.sdi.Run.getLatest;
Use the Simulink.sdi.getSignalsByName
function to access the Stick
signal, which represents the input to the controller, and the alpha, rad
signal, which represents the output.
stick = getSignalsByName(aircraftRun,"Stick"); alpha = getSignalsByName(aircraftRun,"alpha, rad");
Use the signal IDs to compare the Stick
and alpha, rad
signals using the Simulink.sdi.compareSignals
function. The Stick
signal is the baseline. The alpha, rad
signal is the signal to compare against the baseline.
comparisonResults = Simulink.sdi.compareSignals(stick.ID,alpha.ID); match = comparisonResults.Status
match = ComparisonSignalStatus enumeration OutOfTolerance
The comparison result is out of tolerance. You can use the Simulink.sdi.view
function to open the Simulation Data Inspector to view and analyze the comparison results.
Simulink.sdi.view
You can specify time and magnitude tolerance values to use for the comparison. Comparisons use tolerance values specified for the baseline signal in the comparison. To account for the phase shift, set a time tolerance of 1
on the Stick
signal. To account for magnitude differences, set an absolute tolerance value of 0.1
on the Stick
signal.
stick.TimeTol = 1; stick.AbsTol = 0.1;
Compare the signals again. This time, because of the absolute and time tolerances, the signal comparison passes.
comparisonResults = Simulink.sdi.compareSignals(stick.ID,alpha.ID); match = comparisonResults.Status
match = ComparisonSignalStatus enumeration WithinTolerance
Alternatives
You can view and inspect comparison results using the Simulation Data Inspector UI. For more information, see Compare Simulation Data.
Version History
Introduced in R2012b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)