Documentation

Simulink.sdi.DatasetRef class

Package: Simulink.sdi

Access data in Simulation Data Inspector repository

Description

The Simulink.sdi.DatasetRef class provides access to data in the Simulation Data Inspector repository without loading the entire set of data into memory. The class is compatible with the Simulink.SimulationData.DatasetRef class.

Construction

dsr_array = Simulink.sdi.DatasetRef constructs an array containing a Simulink.sdi.DatasetRef object for each run in the Simulation Data Inspector.

dsr_array = Simulink.sdi.DatasetRef(domain) creates an array containing a Simulink.sdi.DatasetRef object for each run, with the contents of each run limited to the selected domain.

dsr = Simulink.sdi.DatasetRef(runID) creates a Simulink.sdi.DatasetRef object of the run corresponding to the run identifier, runID.

dsr = Simulink.sdi.DatasetRef(runID, domain) creates a Simulink.sdi.DatasetRef object of the run corresponding to runID with the contents specified by domain.

dsr = Simulink.sdi.DatasetRef(runID, domain, repositoryPath) creates a Simulink.sdi.DatsetRef object of the run corresponding to runID including the contents specified by domain from a repository path specified by repositoryPath.

Input Arguments

expand all

Limits the contents included in the Simulink.sdi.DatasetRef object.

  • 'signals' includes only logged signals.

  • 'outports' includes only logged outports.

  • [] includes all run data.

Specifies the run containing the data for the Simulink.sdi.DatasetRef object.

Specifies the location of the run containing the data for the Simulink.sdi.DatasetRef object.

Properties

expand all

The name of the run that corresponds with the Simulink.sdi.DatasetRef object.

Example: 'Run 1'

Simulink.sdi.Run object associated with the Simulink.sdi.DatasetRef object.

Number of top-level elements in the Simulink.sdi.Run object associated with the Simulink.sdi.DatasetRef object.

Methods

compare Compare runs with DatasetRef objects
getAsDatastoreRetrieve element as sdidatastore object
getElementRetrieve DatasetRef element by index
getElementNamesGet character vectors of element names
getSignal Return Signal object
plot Open the Simulation Data Inspector to view and compare data

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

expand all

This example shows how to work with the Simulink.sdi.DatasetRef object by comparing two runs of the ex_sldemo_absbrake system with different desired slip ratios.

% Simulate model ex_sldemo_absbrake to create a run of logged signals
load_system('ex_sldemo_absbrake')
sim('ex_sldemo_absbrake')

% Get the runID
runIDs = Simulink.sdi.getAllRunIDs;
runID = runIDs(end);

% Get the run object
run = Simulink.sdi.getRun(runID);

% Make a Simulink.sdi.DatasetRef object
run_DSRef = run.getDatasetRef;

% Get the names of the elements in the object
names = run_DSRef.getElementNames
names =

  2x1 cell array

    {'yout'}
    {'slp' }

% Get yout bus
[yout, name, index] = run_DSRef.getElement(1);

% View signals in outputs
outputs = yout.Values

% Get slp signal
slp = run_DSRef.getSignal('slp');

% Plot signal
slp.Checked = 'true';
outputs = 

  struct with fields:

    Ww: [1x1 timeseries]
    Vs: [1x1 timeseries]
    Sd: [1x1 timeseries]

% Create another run for a different Desired relative slip
set_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 signals
run_DSRef.plot

Introduced in R2017b

Was this topic helpful?