This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Compare Simulation Data

The Simulation Data Inspector can compare the data and metadata for runs and individual signals. You can analyze comparison results using tolerances, and you can control aspects of the comparison through comparison settings. For more information about tolerance calculations and the comparison settings, see How the Simulation Data Inspector Compares Data.

The runs and signals used in this example are relatively small and simple. When you compare long signals or runs containing many signals, the Simulation Data Inspector displays incremental progress indicators during the comparison, and the Compare button becomes a Cancel button you can click to cancel the comparison at any point. For hierarchical data, the Results column in the comparison view summarizes the results on each hierarchical node.

This example uses data generated in Inspect Simulation 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('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 Pilot 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. For example, compare the Stick input signal to the output observed at alpha, rad. Then, specify tolerance values 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 by right-clicking the signal in the Inspect pane.

The signals do not match within the absolute, relative, and time tolerances, all set to 0 by default.

Signal Time Tolerance

Looking at the top plot in the comparison view, you can see the alpha, rad signal lags the Stick signal. For signal comparisons, the Simulation Data Inspector uses tolerance values for the Baseline signal. Add a time tolerance to the Stick signal to account for the lag.

Select the Stick signal and enter 0.5 in the Time Tolerance field of the Properties pane. When you specify a tolerance for a Baseline signal, its Override Global Tolerance field automatically changes to yes. When you click away from the Time Tolerance field, the comparison runs again, using the signal-level tolerance you specified. If you want to use global tolerance values for the signal, click the Override Global Tolerance field and select no from the drop-down.

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 regions within tolerance and out of tolerance for the comparison in green and red.

Signal Magnitude Tolerance

The time tolerance covers the phase difference between the two signals, but the comparison still includes regions out of tolerance due to the amplitude difference. You can add a magnitude tolerance as either an Absolute Tolerance or Relative Tolerance.

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.

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 how the Simulation Data Inspector calculates the tolerance band, see Tolerance Specification.

Compare Runs

You can also use the Simulation Data Inspector to compare signals in a run at once. Run comparisons can 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 and close the Model Explorer.

  3. Simulate the model with the new filter.

  4. On the Compare pane in the Simulation Data Inspector, click the Baseline text box, and select Runs.

  5. From the list of runs, select Run 2: slexAircraftExample.

  6. Click the Compare to text box, and select Runs.

  7. Select Run 3: slexAircraftExample and click Compare.

The Compare pane lists all signals from the compared runs and summarizes the results of the comparison in the Results column. In this example, all three signals aligned, and none matched 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.

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.

Global Tolerances

To qualify signals in the run comparison, you can add global tolerances to the comparison. Change the Global Time Tolerance to 0.75 and the Global Abs Tolerance to 0.075, and click the Compare button to 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 through the 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 keyboard arrows to explore the signal and tolerance values throughout each out of tolerance region. 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