Main Content

getAsDatastore

R2026b

Get matlab.io.datastore.sdidatastore representation of signal in referenced Simulation Data Inspector run

Description

[element,name,idx] = getAsDatastore(dsr,searchIdx) returns a matlab.io.datastore.sdidatastore object, along with the element name and index, for the signal specified by the index searchIdx in the Simulation Data Inspector run referenced by the Simulink.sdi.DatastoreRef object dsr.

[element,name,idx] = getAsDatastore(dsr,searchName) returns a matlab.io.datastore.sdidatastore representation for one or more signals specified by searchName.

example

Examples

collapse all

To create a run of logged signals, simulate the model ThreeSigs.

mdl = "ThreeSigs";
out = sim(mdl);

Get the latest run.

runObj = Simulink.sdi.Run.getLatest;

Create a Simulink.sdi.DatasetRef object that references the Simulation Data Inspector run.

dsRef = getDatasetRef(runObj);

Get the names of the elements in the DatasetRef object.

dsRefNames = getElementNames(dsRef)
dsRefNames = 3×1 cell
    {'sineSig' }
    {'randSig' }
    {'chirpSig'}

Get an sdidatastore object for the sineSig signal. The sdidatastore object is stored in the Values property of the returned Simulink.SimulationData.Signal object.

[sigObj,name,idx] = getAsDatastore(dsRef,"sineSig")
sigObj = 
  Simulink.SimulationData.Signal
  Package: Simulink.SimulationData

  Properties:
              Name: 'sineSig'
    PropagatedName: ''
         BlockPath: [1×1 Simulink.SimulationData.BlockPath]
          PortType: 'inport'
         PortIndex: 1
            Values: [1×1 matlab.io.datastore.sdidatastore]


  Methods, Superclasses
name = 
'sineSig'
idx = 
1

Input Arguments

collapse all

Run from which to get signal data, specified as a Simulink.sdi.DatasetRef object.

Index of signal in the Simulation Data Inspector run referenced by dsr to get as sdidatastore representation, specified as a positive integer.

Example: 3

Name of signal to get as sdidatastore representation, specified as a string or character vector.

Example: "MySignal"

Output Arguments

collapse all

sdidatastore representation of signal from Simulation Data Inspector run, returned as an object whose Values parameter contains a matlab.io.datastore.sdidatastore object, such as a Simulink.SimulationData.Dataset, Simulink.SimulationData.Signal, Simulink.SimulationData.State, or similar object.

Element name, returned as a character vector.

Element index in the Simulation Data Inspector run referenced by the Simulink.sdi.DatasetRef object, returned as a positive integer.

Alternatives

You can construct a sdidatastore object for a specified signal using a matlab.io.datastore.sdidatastore object.

Version History

Introduced in R2017b