Main Content

compare

Compare runs referenced by Simulink.sdi.DatasetRef objects

Description

example

[matches, mismatches, results] = compare(dsr,compRun) returns the number of matches, number of mismatches, and comparison results for a comparison between a Simulation Data Inspector run referenced by a Simulink.sdi.DatasetRef object, dsr, and another run, compRun. The comparison results are returned as a Simulink.sdi.DiffRunResult object.

Examples

collapse all

The model ex_sldemo_absbrake uses a Constant block to specify a slip setpoint for an anti-lock braking system. Simulate the model with two different slip setpoint values, 0.24 and 0.25, and compare the output wheel speed of each simulation run using Simulink.sdi.DatasetRef objects.

Set the value of the Desired relative slip block to 0.25. Then, simulate the model.

load_system("ex_sldemo_absbrake")
set_param("ex_sldemo_absbrake/Desired relative slip", "Value", "0.25")
sim("ex_sldemo_absbrake");

To create another run, change the value of the Desired relative slip block to 0.24 and simulate the model again.

set_param("ex_sldemo_absbrake/Desired relative slip", "Value", "0.24")
sim("ex_sldemo_absbrake");

Create an array of Simulink.sdi.DatasetRef objects corresponding to each run in the Simulation Data Inspector.

DSR_Runs = Simulink.sdi.DatasetRef;

Compare the results from the two runs.

[matches, mismatches, diffResult] = compare(DSR_Runs(1),DSR_Runs(2))
matches = 0
mismatches = 4
diffResult = 
  DiffRunResult with properties:

       MatlabVersion: '23.2.0.2358603 (R2023b)'
              RunID1: 10510
              RunID2: 10550
     BaselineRunName: 'Run 1: ex_sldemo_absbrake'
    CompareToRunName: 'Run 2: ex_sldemo_absbrake'
               Count: 4
         DateCreated: 19-Aug-2023 17:43:07
     GlobalTolerance: [1x1 struct]
             Summary: [1x1 struct]
             Options: {'Units'  'MustMatch'}
              Status: Completed
          StopReason: []

Input Arguments

collapse all

Referenced baseline run, specified as a Simulink.sdi.DatasetRef object.

Comparison run, specified as a Simulink.sdi.DatasetRef object or a workspace variable containing time-based data such as a Simulink.SimulationData.Dataset object, Simulink.SimulationData.DatasetRef object, or a timeseries object. Comparison data must be time-based data in which sample values are associated with sample times.

Output Arguments

collapse all

Number of matching signals within tolerance in the comparison, returned as a nonnegative integer.

Number of mismatched signals, returned as a nonnegative integer.

Results of the comparison, returned in a Simulink.sdi.DiffRunResult object.

Alternatives

You can create runs for the data and use the Simulink.sdi.compareRuns function for the comparison. You can also view runs created from a simulation, import data to runs, and compare runs with the Simulation Data Inspector.

Version History

Introduced in R2017b