Main Content

getAsDatastore

Class:Simulink.SimulationData.DatasetRef
Package:Simulink.SimulationData

Get matlab.io.datastore.SimulationDatastore representation of element from referenced Dataset object

Syntax

element = Simulink.SimulationData.DatasetRef.getAsDatastore(datasetref_elements)

Description

element = Simulink.SimulationData.DatasetRef.getAsDatastore(datasetref_elements)返回一个matlab.io.datastore.SimulationDatastore表示一个元素或elem的集合ents from the referenced dataset, based on index, name, or block path of the element.

You can represent aDatasetelement as amatlab.io.datastore.SimulationDatastoreobject if the element was placed into the MAT-file using either of these approaches:

  • LogDatasetformat data to persistent storage (MAT-file).

  • Place the element into aSimulink.SimulationData.Datasetobject and saved theDatasetobject to a v7.3 MAT-file.

TheSimulationDatastorerepresentation for aDatasetelement creates a SimulationDatastore object for the Values field of that element. TheSimulationDatastorerepresentation supports streaming of the data for theValuesproperty of the element into other simulations or into MATLAB®.

Note

You cannot use create aSimulationDatastoreforDatasetelements that contain these types of data:

  • Array

You can useSimulationDatastoreobjects to:

  • Refer to logged simulation data that is stored on disk in a MAT-file.

  • Specify signals to stream incrementally from disk to a simulation.

  • Provide a basis for big data analysis using MATLAB functions.

Input Arguments

expand all

Element of a referenced dataset in a MAT-file, specified as an index, name (as a character vector), or block path (as a character vector.

Output Arguments

expand all

Element accessed usingSimulationDatastoreobject, returned as either amatlab.io.datastore.SimulationDatastoreobject or aSimulink.Signal,Simulink.State, or similar object, whoseValuesdata uses amatlab.io.datastore.SimulationDatastoreobject.

Examples

expand all

Log signal data to persistent storage (select theLog Dataset data to fileconfiguration parameter) and simulate a model.

Create aDatasetReffor the signal loggingDatasetdata (logsout) in theout.matMAT-file.

sigLogRef = Simulink.SimulationData.DatasetRef('out.mat','logsout'); firstSig = sigLogRef.getAsDatastore(1)
firstSig = Simulink.SimulationData.Signal Package: Simulink.SimulationData Properties: Name: 'x1' PropagatedName: '' BlockPath: [1x1 Simulink.SimulationData.BlockPath] PortType: 'outport' PortIndex: 1 Values: [1×1 matlab.io.datastore.SimulationDatastore]

Load the data into another model. This approach streams the values of the signalx1for another simulation.

ds = Simulink.SimulationData.Dataset; ds{1} = sigLogRef{1}; sim('other_model','ExternalInput','ds');

Alternative

To streamline the use of indexing, you can use curly braces ({}) syntax to obtain aSimulationDatastoreobject forDatasetRefobject signal values. The requirements and results are the same as usinggetAsDatastore. For example, if you log signal data to persistent storage (select theLog Dataset data to fileconfiguration parameter) and simulate a model.

sigLogRef = Simulink.SimulationData.DatasetRef('out.mat','logsout'); firstSig = sigLogRef{1}
ans = 金宝appSimulink.SimulationData.Signal Package: Simulink.SimulationData Properties: Name: 'x1' PropagatedName: '' BlockPath: [1x1 Simulink.SimulationData.BlockPath] PortType: 'outport' PortIndex: 1 Values: [1×1 matlab.io.datastore.SimulationDatastore]
Introduced in R2017a