Main Content

Simulink.sdi.DatasetRef class

Package: Simulink.sdi

Access data in Simulation Data Inspector repository

Description

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

Construction

dsr_array = Simulink.sdi.DatasetRef constructs an array that contains a Simulink.sdi.DatasetRef object that corresponds to each run in the Simulation Data Inspector.

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

dsr = Simulink.sdi.DatasetRef(runID) creates a Simulink.sdi.DatasetRef object that references the run specified by the run identifier, runID.

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

dsr = Simulink.sdi.DatasetRef(runID, domain, repositoryPath) creates a Simulink.sdi.DatsetRef object that references the run specified by the run identifier, runID. The DatasetRef object contains the contents specified by domain from the repository specified by repositoryPath.

Input Arguments

expand all

Data to reference in DatasetRef object, specified as one of the following:

  • 'signals' — Signals produced by signal logging.

  • 'outports' — Model output signals, represented by top-level Outport blocks.

  • 'dsm'Data Store Memory blocks.

  • 'state' — Simulink® states.

  • 'param' — Parameter data for block parameters and variables tuned using dashboard blocks.

  • 'sf_data' — Stateflow® local data.

  • 'sf_state' — Stateflow states.

  • 'sf_state_child' — Stateflow child activity.

  • 'sf_state_leaf' — Stateflow leaf activity.

  • 'slt_verify'Assertion blocks and verify assessments in Simulink Test™.

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.

Examples

collapse 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
brakeRun = Simulink.sdi.getRun(runID);

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

% Get the names of the elements in the object
names = run_DSRef.getElementNames
names = 2x1 cell
    {'yout'}
    {'slp' }

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

% View signals in outputs
outputs = yout.Values
outputs = struct with fields:
    Ww: [1x1 timeseries]
    Vs: [1x1 timeseries]
    Sd: [1x1 timeseries]

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

% Plot signal
slp.Checked = 'true';
% 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