Main Content

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:

Properties

expand all

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

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 the intersection 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 to double 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.

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.

This property is read-only.

Unique signal identifier for the baseline signal in the comparison, returned as an integer.

This property is read-only.

Unique signal identifier for the signal to compare against the baseline signal, returned as an integer.

This property is read-only.

Maximum difference between the two comparison signals, returned as a double.

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.

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.

This property is read-only.

Difference signal resulting from the comparison, returned as a timeseries object.

Examples

collapse all

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

First, load the session that contains the data.

Simulink.sdi.load('AircraftExample.mldatx');

Use the Simulink.sdi.Run.getLatest function to access the latest run in the data.

aircraftRun = Simulink.sdi.Run.getLatest;

Then, you can use the Simulink.sdi.getSignalsByName function to access the Stick signal, which represents the input to the controller, and the alpha, rad signal that represents the output.

stick = getSignalsByName(aircraftRun,'Stick');
alpha = getSignalsByName(aircraftRun,'alpha, rad');

Before you compare the signals, you can specify a tolerance value to use for the comparison. Comparisons use tolerance values specified for the baseline signal in the comparison, so set an absolute tolerance value of 0.1 on the Stick signal.

stick.AbsTol = 0.1;

Now, compare the signals using the Simulink.sdi.compareSignals function. The Stick signal is the baseline, and 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.

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