Main Content

plotComparison

Plot comparison results on Simulink.sdi.CustomSnapshot objects

Since R2023a

Description

plotComparison(snap,diffSignalResult) plots the signal comparison result diffSignalResult on the Simulink.sdi.CustomSnapshot object snap.

When you use the plotComparison function to plot comparison results to a Simulink.sdi.CustomSnapshot object, you can only customize the Width and Height properties of the Simulink.sdi.CustomSnapshot object. When you take a snapshot of comparison results, the Simulink.sdi.CustomSnapshot object will always have 2×1 subplot layout. A fit-to-view is performed to determine the axis limits.

example

Examples

collapse all

You can use the function plotComparison to plot comparison results to a Simulink.sdi.CustomSnapshot object. This example uses data collected by simulating a model of an aircraft longitudinal flight control system and captures a snapshot of the contents of the comparison results in the Simulation Data Inspector. When you use a Simulink.sdi.CustomSnapshot object to create the snapshot, you can adjust the look of the figure without affecting the Simulation Data Inspector. For more information about the model, see Aircraft Longitudinal Flight Control.

First, load the session file that contains the data to compare. The session file contains data for four simulations of an aircraft longitudinal controller. This example compares data from two runs that use different input filter time constants.

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

Access the run IDs that correspond to the last two simulation runs.

runIDs = Simulink.sdi.getAllRunIDs;
baselineID = runIDs(end-1);
comparedToID = runIDs(end);

Use the Simulink.sdi.compareRuns function to compare the last two runs. Specify a global time tolerance of 0.8.

diffResult = Simulink.sdi.compareRuns(baselineID,comparedToID,"TimeTol",0.8);

Use the getResultsByName function to access the comparison results for the q rad/sec signal.

qResult = getResultsByName(diffResult,"q, rad/sec");

Create a Simulink.sdi.CustomSnapshot object and plot the comparison results on it. Then, use the snapshot function to generate the figure.

snap = Simulink.sdi.CustomSnapshot;
plotComparison(snap,qResult);
snapshot(snap,"To","image");

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

Custom snapshot settings, specified as a Simulink.sdi.CustomSnapshot object.

Signal comparison result, specified as a Simulink.sdi.DiffSignalResult object.

Version History

Introduced in R2023a