Documentation

Compare Simulation Data

The Simulation Data Inspector compares the data and metadata for runs and individual signals. You can analyze comparison results with the difference plot and tolerance features. You can control the comparison through comparison settings. For more information on the comparison settings, see How the Simulation Data Inspector Compares Data.

Setup

This example continues from Inspect Simulation Data. You can also use this script to generate the data required for the example.

% Load system
load_system('slexAircraftExample')

% Configure signals to log
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Pilot', 1, 'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model', 3, 'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model', 4, 'on')

% Change Pilot signal to sine
set_param('slexAircraftExample/Pilot', 'WaveForm', 'sine')

% Simulate model
sim('slexAircraftExample')

% Change Pilog signal to square
set_param('slexAircraftExample/Pilot', 'WaveForm', 'square')

% Simulate Model
sim('slexAircraftExample')

Compare Signals

You can compare signals to analyze the relationship between your model's inputs and outputs. Compare the Stick input signal to the output observed at alpha, rad. Then, use the tolerance feature in the Simulation Data Inspector to analyze the result.

To compare the alpha, rad signal to the Stick signal:

  1. Navigate to the Compare pane.

  2. To view a list of signals available for comparison, click the Baseline text box, and select Signals.

  3. Select Stick (Run 1: slexAircraftExample).

  4. Click the Compare to text box, and select Signals.

  5. Select alpha, rad (Run 1: slexAircraftExample).

  6. Click Compare.

Alternatively, you can select the Baseline and Compare to signals through the context menu when you right-click a signal in the Inspect pane.

Here, the alpha, rad and Stick signals are compared from Run 1. The signals do not match within the absolute, relative, and time tolerances, all specified as 0 by default.

From a visual inspection of the signals, you can see alpha, rad lags Stick. Add a time tolerance to the Stick signal to account for the lag.

  1. In the properties pane, click the Override Global Tolerance baseline value field, and select yes from the drop-down.

    When the Override Global Tolerance field is set to yes, the tolerance values in the signal properties are applied instead of the global tolerances specified above the graphical viewing area.

  2. Enter 0.5 into the Time Tolerance field in the properties pane to the left of the graphical viewing area.

    The comparison automatically runs again, with the updated tolerance value.

    The Simulation Data Inspector draws the tolerance band around the plotted Baseline signal and around the signed difference signal displayed in the bottom subplot. The bar along the top of the difference plot shows pass and out of tolerance regions for the comparison in green and red.

    Note

    The Simulation Data Inspector draws the tolerance region with the most lenient interpretation of the specified tolerances for each point. For more information on tolerances, see Tolerances in the Simulation Data Inspector.

The time tolerance covers the phase difference between the two signals, but the comparison still does not pass due to the amplitude difference. To add an absolute tolerance to the Stick signal, enter 0.05 into the Absolute Tolerance field in the properties pane.

With the combination of the absolute and time tolerances, the signal comparison passes.

Compare Runs

You can also use the Simulation Data Inspector to compare all logged signals in a model at once by comparing runs. Run comparisons provide useful information about the effects of changing model parameters. For example, change the frequency cutoff of the filter for the control stick input signal. Then, evaluate the effect on the output signal with the Simulation Data Inspector.

  1. Click the Model Explorer button to access the Model Workspace variables.

  2. Change the value of Ts in the Model Workspace from 0.1 to 1.

  3. Close the Model Explorer.

  4. Simulate the model with the new filter.

  5. In the Simulation Data Inspector, click Compare to switch to the Compare pane.

  6. Click the Baseline text box, and select Run 2: slexAircraftExample.

  7. Click the Compare to text box, and select Run 3: slexAircraftExample.

  8. Click Compare.

The Compare pane lists all signals from the runs with a comparison result. In this example, the comparison results of the aligned signals do not match. The signal differences are not within the specified tolerance values, all of which are set to zero.

Note

The Simulation Data Inspector only compares signals from the Baseline run that align with a signal from the Compare To run. If a signal from the Baseline run does not align with a signal from the Compare To run, the signal is listed in the Compare pane with a warning. For more information on signal alignment, see Signal Alignment in the Simulation Data Inspector.

To plot comparison data, select the signal you want to see in the Compare pane. Here, the top plot shows the q, rad/sec signals from the Baseline and Compare To runs. The bottom plot shows the difference between the signals and a graphical representation of the tolerance.

To qualify signals in the run comparison, you can add global tolerances to the comparison using the global tolerance fields above the graphical viewing area. Enter one or more desired tolerance values, and click Compare to run the comparison again with the new tolerance values. Change the Global Time Tolerance to 0.75 and the Global Abs Tolerance to 0.075, and run the comparison. The Simulation Data Inspector draws the tolerance band around the Baseline signal and on the signed difference plot on the lower half of the graphical viewing area. With the new tolerance values, the Stick and q, rad/sec signals pass the comparison.

View the alpha, rad signal to analyze the comparison's out of tolerance regions. Click the arrow buttons in the tool strip to navigate to the comparison's out of tolerance regions. Two cursors on the plot show the beginning and end of the first out of tolerance region. You can use your mouse arrows to explore the signal and tolerance values. To view the next out of tolerance region, click the right arrow button in the tool strip.

To resolve the out of tolerance regions, you can choose to modify the global tolerance values or to add a signal specific tolerance to the alpha, rad signal using the signal properties.

Related Topics

Was this topic helpful?