Main Content

How the Simulation Data Inspector Compares Data

You can tailor the Simulation Data Inspector comparison process to fit your requirements in multiple ways. When comparing runs, the Simulation Data Inspector:

  1. Aligns signal pairs in the Baseline and Compare To runs based on the Alignment settings.

    The Simulation Data Inspector does not compare signals that it cannot align.

  2. Synchronizes aligned signal pairs according to the specified Sync Method.

    Values for time points added in synchronization are interpolated according to the Interpolation Method specified for the Baseline signal.

  3. Computes the difference of the signal pairs.

    For all signal data types other than double, the software upcasts the data to double for comparison.

  4. Compares the difference result against specified tolerances.

When the comparison run completes, the results of the comparison are displayed in the navigation pane.

StatusComparison Result

Difference falls within the specified tolerance.

Difference violates specified tolerance.

The signal does not align with a signal from the Compare To run.

When you compare signals with differing time intervals, the Simulation Data Inspector compares the signals on their overlapping interval.

Signal Alignment

In the alignment step, the Simulation Data Inspector decides which signal from the Compare To run pairs with a given signal in the Baseline run. When you compare signals with the Simulation Data Inspector, you complete the alignment step by selecting the Baseline and Compare To signals.

The Simulation Data Inspector aligns signals using a combination of their Data Source, Path, SID, and Signal Name properties.

PropertyDescription
Data SourceName of the variable in the MATLAB® workspace
PathBlock path for the source of the data in its model
SID

Automatically assigned Simulink® identifier

Signal NameName of the signal in the model

With the default alignment settings, the Simulation Data Inspector aligns signals between runs according to this flow chart.

Flow chart of how the Simulation Data Inspector aligns signals.

You can specify the priority for each of the signal properties used for alignment in the Simulation Data Inspector Preferences. The Align By field specifies the highest priority property used to align signals. The priority drops with each subsequent Then By field. You must specify a primary alignment property in the Align By field, but you can specify any number of the Then By fields as None.

Synchronization

Often, signals that you want to compare don't contain the exact same set of time points. The synchronization step in Simulation Data Inspector comparisons resolves discrepancies in signals' time vectors. You can choose union or intersection as the synchronization method.

When you specify union synchronization, the Simulation Data Inspector builds a time vector that includes every sample time between the two signals. For each sample time not originally present in either signal, the Simulation Data Inspector interpolates the value. The second graph in the illustration shows the union synchronization process, where the Simulation Data Inspector identifies samples to add in each signal, represented by the unfilled circles. The final plot shows the signals after the Simulation Data Inspector has interpolated values for the added time points. The Simulation Data Inspector computes the difference using the signals in the final graph, so that the computed difference signal contains all the data points between the signals over the intersecting time region.

When you compare two signals and specify union synchronization, the Simulation Data Inspector interpolates the value for any sample time not originally present in either signal.

When you specify intersection synchronization, the Simulation Data Inspector uses only the sample times present in both signals in the comparison. In the second graph, the Simulation Data Inspector identifies samples that do not have a corresponding sample for comparison, shown as unfilled circles. The final graph shows the signals used for the comparison, without the samples identified in the second graph.

When you compare two signals and specify intersection synchronization, the Simulation Data Inspector uses only values from the sample times present in both sample times.

It is recommended to use union synchronization because it provides a more precise result. When you use intersection synchronization, the comparison finishes quickly because the Simulation Data Inspector computes the difference for fewer data points and does not interpolate. However, some data is discarded and precision lost with intersection synchronization.

Interpolation

The interpolation property of a signal determines how the Simulation Data Inspector displays the signal and how additional data values are computed in synchronization. When you compare two signals, the Simulation Data Inspector uses the Interpolation Method specified for the Baseline signal for both the Baseline and Compare To signals. You can choose to interpolate your data with a zero-order hold (zoh) or a linear approximation. You can also specify no interpolation.

Three plots of sine wave. The first plot uses linear interpolation. The second plot uses zero-order hold interpolation. the third plot uses no interpolation.

When you specify zoh or none for the Interpolation Method, the Simulation Data Inspector replicates the data of the previous sample for interpolated sample times. When you specify linear interpolation, the Simulation Data Inspector uses samples on either side of the interpolated point to linearly approximate the interpolated value. Typically, discrete signals use zoh interpolation and continuous signals use linear interpolation. You can specify the Interpolation Method for your signals in the signal properties.

Tolerance Specification

The Simulation Data Inspector allows you to specify the scope and value of the tolerance for your signal. You can define a tolerance band using any combination of absolute, relative, and time tolerance values, and you can specify whether the specified tolerance applies to an individual signal or to all the signals in a run.

Tolerance Scope

In the Simulation Data Inspector, you can specify the tolerance for your data globally or for an individual signal. Global tolerance values apply to all signals in a run that do not have Override Global Tol set to yes. You can specify global tolerance values for your data at the top of the graphical viewing area in the Compare view. To specify signal specific tolerance values, edit the signal properties and ensure the Override Global Tol property is set to yes.

Tolerance Computation

In the Simulation Data Inspector, you can specify a tolerance band for your run or signal using a combination of absolute, relative, and time tolerance values. When you specify the tolerance for your run or signal using multiple types of tolerances, each tolerance can yield a different answer for the tolerance at each point. The Simulation Data Inspector computes the overall tolerance band by selecting the most lenient tolerance result for each data point.

When you define your tolerance using only the absolute and relative tolerance properties, the Simulation Data Inspector computes the tolerance for each point as a simple maximum.

tolerance = max(absoluteTolerance,relativeTolerance*abs(baselineData));

The upper boundary of the tolerance band is formed by adding tolerance to the Baseline signal. Similarly, the Simulation Data Inspector computes the lower boundary of the tolerance band by subtracting tolerance from the Baseline signal.

When you specify a time tolerance, the Simulation Data Inspector evaluates the time tolerance first, over a time interval defined as [(tsamp-tol), (tsamp+tol)] for each sample. The Simulation Data Inspector builds the lower tolerance band by selecting the minimum point on the interval for each sample. Similarly, the maximum point on the interval defines the upper tolerance for each sample.

The Simulation Data Inspector uses the maximum and minimum value present in the specified time interval to define the upper and lower tolerance, respectively.

If you specify a tolerance band using an absolute or relative tolerance in addition to a time tolerance, the Simulation Data Inspector applies the time tolerance first, and then applies the absolute and relative tolerances to the maximum and minimum points selected with the time tolerance.

When you specify an absolute or relative tolerance in addition to a time tolerance, the tolerance band increases.

upperTolerance = max + max(absoluteTolerance,relativeTolerance*max)

lowerTolerance = min - max(absoluteTolerance,relativeTolerance*min)

Limitations

The Simulation Data Inspector does not support comparing:

  • Before R2020a: Signals of data types int64 or uint64.

  • Variable-size signals.

Related Topics