Documentation

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, seeHow 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 theComparebutton becomes aCancelbutton you can click to cancel the comparison at any point. For hierarchical data, theResultscolumn in the comparison view summarizes the results on each hierarchical node.

This example uses data generated inInspect Simulation Data

Setup

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

load_system('slexAircraftExample')% Configure signals to logSimulink.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 sineset_param('slexAircraftExample/Pilot','WaveForm','sine')% Simulate modelsim卡('slexAircraftExample')% Change Pilot signal to squareset_param('slexAircraftExample/Pilot','WaveForm','square')% Simulate Modelsim卡('slexAircraftExample')

Compare Signals

You can compare signals to analyze the relationship between your model's inputs and outputs. For example, compare theStickinput signal to the output observed atalpha, rad。Then, specify tolerance values to analyze the result.

To compare thealpha, radsignal to theSticksignal:

  1. Navigate to theComparepane.

  2. To view a list of signals available for comparison, click theBaselinetext box, and selectSignals

  3. SelectStick (Run 1: slexAircraftExample)

  4. Click theCompare totext box, and selectSignals

  5. Selectalpha, rad (Run 1: slexAircraftExample)

  6. ClickCompare

Alternatively, you can select theBaselineandCompare tosignals through the context menu by right-clicking the signal in theInspectpane.

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 thealpha, radsignal lags theSticksignal. For signal comparisons, the Simulation Data Inspector uses tolerance values for theBaselinesignal. Add a time tolerance to theSticksignal to account for the lag.

Select theSticksignal and enter0.5in theTime Tolerancefield of thePropertiespane. When you specify a tolerance for aBaselinesignal, itsOverride Global Tolerancefield automatically changes toyes。When you click away from theTime Tolerancefield, the comparison runs again, using the signal-level tolerance you specified. If you want to use global tolerance values for the signal, click theOverride Global Tolerancefield and selectnofrom the drop-down.

The Simulation Data Inspector draws the tolerance band around the plottedBaselinesignal 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 anAbsolute ToleranceorRelative Tolerance

To add an absolute tolerance to theSticksignal, enter0.05into theAbsolute Tolerancefield 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, seeTolerance 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 theModel Explorerbuttonto access theModel Workspacevariables.

  2. Change the value ofTsin theModel Workspacefrom0.1to1and close theModel Explorer

  3. Simulate the model with the new filter.

  4. On theComparepane in the Simulation Data Inspector, click theBaselinetext box, and selectRuns

  5. From the list of runs, selectRun 2: slexAircraftExample

  6. Click theCompare totext box, and selectRuns

  7. SelectRun 3: slexAircraftExampleand clickCompare

TheComparepane lists all signals from the compared runs and summarizes the results of the comparison in theResultscolumn. 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 theBaselinerun that align with a signal from theCompare Torun. If a signal from theBaselinerun does not align with a signal from theCompare Torun, the signal is listed in theComparepane with a warning.。为更多的信息ignal alignment, seeSignal Alignment

To plot comparison data, select the signal you want to see in theComparepane. Here, the top plot shows theq, rad/secsignals from theBaselineandCompare Toruns. 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 theGlobal Time Toleranceto0.75and theGlobal Abs Toleranceto0.075, and click theComparebutton to run the comparison. The Simulation Data Inspector draws the tolerance band around theBaselinesignal and on the signed difference plot on the lower half of the graphical viewing area. With the new tolerance values, theStickandq, rad/secsignals pass the comparison.

View thealpha, radsignal to analyze the comparison's out of tolerance regions. Click the arrow buttons在浏览工具条的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 thealpha, radsignal using the signal properties.

Related Topics