Save comparison results to an MLDATX file
saves the comparison results in the
DiffRes, and original run data to the MLDATX file,
fileName. You can load the MLDATX file containing the runs and
comparison results into the Simulation Data Inspector using the
You can specify global tolerance values to use when comparing two simulation runs. Global tolerance values are applied to all signals within the run. This example shows how to specify global tolerance values for a run comparison and how to analyze and save the comparison results.
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.
To access the run data to compare, use the
Simulink.sdi.getAllRunIDs function to get the run IDs that correspond to the last two simulation runs.
runIDs = Simulink.sdi.getAllRunIDs; runID1 = runIDs(end - 1); runID2 = runIDs(end);
Simulink.sdi.compareRuns function to compare the runs. Specify a global relative tolerance value of
0.2 and a global time tolerance value of
runResult = Simulink.sdi.compareRuns(runID1,runID2,'reltol',0.2,'timetol',0.5);
Summary property of the returned
Simulink.sdi.DiffRunResult object to see whether signals were within the tolerance values or out of tolerance.
ans = struct with fields: OutOfTolerance: 0 WithinTolerance: 3 Unaligned: 0 UnitsMismatch: 0 Empty: 0 Canceled: 0 EmptySynced: 0 DataTypeMismatch: 0 TimeMismatch: 0 StartStopMismatch: 0 Unsupported: 0
All three signal comparison results fell within the specified global tolerance.
You can save the comparison results to an MLDATX file using the
DiffRes— Run comparison results
Run comparison results that contain the data you want to save, specified as a
fileName— MLDATX file name
Name of the MLDATX file where you want to save the results, specified as a string or character array.
saveRuns— Whether to save original run data
Whether to save the original run data for the compared runs, specified as a logical
false). By default, the
saves the original run data along with the comparison results.