Main Content

compare

Class:Simulink.sdi.DatasetRef
Package:Simulink.sdi

Compare runs with DatasetRef objects

Syntax

[匹配,不匹配的结果s] = dsrObj.compare(other)

Description

[matches,mismatches,results] = dsrObj.compare(other)returns the number of matches, number of mismatches, and comparison results for a comparison of data in aSimulink.sdi.DatasetRefobject. The comparison results are returned as aSimulink.sdi.DiffRunResultobject.

Input Arguments

expand all

Comparison data, which can come from anotherSimulink.sdi.DatasetRefobject, aDatasetin the workspace, or a MAT-file.

Example:'data.mat'

Example:var

Output Arguments

expand all

Number of signals that matched within tolerance in the comparison.

Number of signals that did not match within tolerance in the comparison.

Results of the comparison, returned in aSimulink.sdi.DiffRunResultobject.

Examples

expand all

This example shows how to work with theSimulink.sdi.DatasetRefobject by comparing two runs of theex_sldemo_absbrakesystem with different desired slip ratios.

% Simulate model ex_sldemo_absbrake to create a run of logged signalsload_system('ex_sldemo_absbrake') sim('ex_sldemo_absbrake')% Get the runIDrunIDs = Simulink.sdi.getAllRunIDs; runID = runIDs(end);% Get the run objectbrakeRun = Simulink.sdi.getRun(runID);% Make a Simulink.sdi.DatasetRef objectrun_DSRef = brakeRun.getDatasetRef;% Get the names of the elements in the object的名字= run_DSRef.getElementNames
的名字=2x1 cell{'yout'} {'slp' }
% Get yout bus[yout, name, index] = run_DSRef.getElement(1);% View signals in outputs输出=你。值
outputs =struct with fields:Ww: [1x1 timeseries] Vs: [1x1 timeseries] Sd: [1x1 timeseries]
% Get slp signalslp = run_DSRef.getSignal('slp');% Plot signalslp.Checked ='true';
% Create another run for a different Desired relative slipset_param('ex_sldemo_absbrake/Desired relative slip','Value','0.25') sim('ex_sldemo_absbrake') DSR_Runs = Simulink.sdi.DatasetRef;% Compare the results from the two runs[matches, mismatches, diffResult] = run_DSRef.compare(DSR_Runs(2));% Open the Simulation Data Inspector to view signalsrun_DSRef.plot

Alternatives

Using the Simulation Data Inspector API, you could create runs for the data you want to compare and useSimulink.sdi.compareRunsfor the comparison. You can also view runs created from simulation, import data to runs, and compare runs with the Simulation Data Inspector UI.

Version History

Introduced in R2017b