Simulink.SimulationData.Dataset
Access logged simulation data or group simulation input data
Description
A Simulink.SimulationData.Dataset
object groups related data.
Logged simulation results are often grouped in Dataset
objects. You can
also use a Dataset
object to group simulation input data when you load
initial states and when you load external input data using Inport blocks or the Signal
Editor block.
A Dataset
object created by logging simulation data contains one or
more elements. Each element contains data for one logged signal, output, data store, or
state. Each element is an object, and the type of the object depends on the data it contains.
Signals and outputs —
Simulink.SimulationData.Signal
objectStates and final states —
Simulink.SimulationData.State
objectData stores —
Simulink.SimulationData.DataStoreMemory
object
When you create a Dataset
object that groups simulation input data,
each element contains data for a signal, bus, or array of buses. You can add data in any
format supported by the loading method you use.
Type of Input | Data Formats |
---|---|
Scalar, vector, or multidimensional signal |
|
Bus |
|
Array of buses |
|
Function-call signal |
|
Creation
Logging simulation data often creates a
Simulink.SimulationData.Dataset
object, including when you:
Log data using signal logging.
Log outputs, states, or final states using the
Dataset
format.Log data stores.
Log data to the workspace or a MAT file using the Record block.
Log data in
Dataset
format using a Scope block.Log data using a Floating Scope or Scope Viewer.
To group external input data for a model in a Dataset
object, you can:
Create an empty
Dataset
object and add the input data using theaddElement
function.Use the
createInputDataset
to create aDataset
object that contains an element for each root-level Inport block or In Bus Element block in a model. Then, specify the data for each element.Use the Signal Editor to interactively create and edit
Dataset
objects that contain simulation input data. For details, see Create and Edit Signal Data.
You can also create a Dataset
object by converting data that uses
another format to use the Dataset
format. Having all data in
a common format can facilitate postprocessing. For details, see Convert timeseries Object to Dataset Object.
Syntax
Description
creates an empty, unnamed ds
= Simulink.SimulationData.DatasetDataset
object to which you can add
elements. Use this syntax to manually create a Dataset
object
that contains external input data to load using Inport or
In Bus Element blocks.
creates an unnamed ds
= Simulink.SimulationData.Dataset(dataToConvert
)Dataset
object that contains one or more
elements that contain the data dataToConvert
. Use this syntax
to convert data that uses another format to use the
Dataset
format. For details, see Convert timeseries Object to Dataset Object.
The conversion process only converts data for one input at a time. To convert
data for multiple variables, convert each variable one at a time, then use the
concat
function to combine the resulting
Dataset
objects.
creates a ds
= Simulink.SimulationData.Dataset(dataToConvert
,"DatasetName",dsName
)Dataset
object with the name specified by
dsName
that contains one or more elements that contain
the data dataToConvert
. Use this syntax to convert data that
uses another format to use the Dataset
format. For
details, see Convert timeseries Object to Dataset Object.
Input Arguments
Output Arguments
Properties
Object Functions
addElement | Add element to end of Simulink.SimulationData.Dataset
object |
concat | Concatenate Simulink.SimulationData.Dataset object to another
Dataset object |
exportToPreviousRelease | Save a Dataset object to a MAT-file you can open in any
release |
extractTimetable | Extract data from Simulink.SimulationData.Dataset or
Simulink.SimulationData.Signal objects into timetables |
find | Get element or collection of elements from
Simulink.SimulationData.Dataset object |
get | Get element or collection of elements from
Simulink.SimulationData.Dataset object |
getElementNames | Return names of all elements in Simulink.SimulationData.Dataset
object |
numElements | Get number of elements in Simulink.SimulationData.Dataset
object |
plot | Plot data in Simulation Data Inspector |
removeElement | Remove element from Simulink.SimulationData.Dataset
object |
setElement | Change Simulink.SimulationData.Dataset object element stored at
specified index |
Examples
Tips
You can use curly braces (
{}
) to access, add, or modify an element in aDataset
object by index.To access, add, or modify an element of a
Dataset
object by name, use thegetElement
,addElement
, andsetElement
functions.When you group simulation inputs using
Dataset
objects, you can use the Signal Editor or the Signal Editor block to easily change whichDataset
object provides input for the simulation.When you load external input data from a
Dataset
object using root-level Inport blocks, you can use the Root Inport Mapper to map each element in theDataset
object to an Inport block by block name, block path, signal name, or port order. You can also write your own function to map the data. For more information, see Map Root Inport Signal Data.When you save data in a
Dataset
object to a MAT file, consider saving to a Version 7.3 MAT file if the contents of theDataset
object are too large to fit in memory. You can create aSimulink.SimulationData.DatasetRef
that references aDataset
object in a MAT file without loading the data into memory for data processing or for loading big data. For more information, see Load Big Data for Simulations.To save a
Dataset
object to a MAT file that you can open in an earlier release, use theexportToPreviousRelease
function instead of thesave
function.You can write your own reader to import data from a file into a
Dataset
object in the base workspace, the model workspace, or the Signal Editor using theSimulink.io.FileType
class. For more information, see Create Custom File Type for Import.
Version History
Introduced in R2011aSee Also
Objects
Simulink.SimulationOutput
|Simulink.SimulationData.Signal
|timeseries
|timetable
|Simulink.SimulationData.DatasetRef
Functions
Model Settings
- Signal logging | Output | States | Data stores | Final states | Format | Single simulation output | Input