Documentation

Simulink.SimulationData.Dataset class

Package: Simulink.SimulationData

Create Simulink.SimulationData.Dataset object

Description

Simulink® creates Simulink.SimulationData.Dataset objects to store data elements when:

  • Performing signal logging, if you use the default signal logging format of Dataset

  • Logging states or outputs, if you set the format to Dataset.

  • Logging a data store

Using the Dataset format for signal logging offers several advantages compared to the ModelDataLogs format. For a discussion of those advantages, see Signal logging format. Unlike the handle-based ModelDataLogs class, Simulink.SimulationData.Dataset is a value class. For details, see Handle Versus Value Classes.

Using the Dataset format for state and output logging offers several advantages compared to Array, Structure, or Structure with time. For details, see Format for State Information Saved Without SimState.

Simulink.SimulationData.Dataset provides a getElement method for accessing individual elements in the data set. You can specify an element by index, name, or block path.

Construction

convertedDataset = Simulink.SimulationData.Dataset(loggedDataToConvert) converts the loggedDataToConvert to a Simulink.SimulationData.Dataset object. You can then use the Simulink.SimulationData.DataSet.concat method to combine elements of two Dataset objects.

constructedDataset = Simulink.SimulationData.Dataset(variableName,'DatasetName','dsname') constructs a Simulink.SimulationData.Dataset object, adds variable variableName, and names the data set dsname.

Input Arguments

collapse all

loggedDataToConvert — Data element to convertstring

Data element to convert to a data set, specified as a string. You can convert elements such as:

  • Array

  • Structure

  • Structure with time

  • MATLAB® time series

  • Structure of MATLAB time-series elements

  • ModelDataLogs

variableName — Variable to add to data setstring

Variable to add to data set, specified as a string.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'DatasetName','dsname'

'DatasetName' — Data set namestring

Data set name, specified as a string.

Output Arguments

collapse all

convertedDataset — Converted data setSimulink.SimulationData.Dataset object

Converted data set, returned as a Simulink.SimulationData.Dataset object.

constructedDataset — Constructed data setSimulink.SimulationData.Dataset object

Constructed data set, returned as a Simulink.SimulationData.Dataset object.

Properties

collapse all

NameName of the data setsame as the logging variable (default) | string

Name of the data set, specified as a string or logging variable (for example, logsout for signal logging). Specify a name when you want to distinguish easily one data set from another. For example, you could reset the name when comparing multiple simulations. This property is read/write.

ds = Simulink.SimulationData.Dataset
ds.Name = 'Dataset1'

Total ElementsTotal number of elementsdouble

Total number of elements in data set, specified as a double. This property is read only. To get this value, use the Simulink.SimulationData.DataSet.numElements method.

Methods

addElementAdd element to end of data set
concatConcatenate dataset to another dataset
getGet element or collection of elements from dataset
getElementNamesReturn names of all elements in dataset
numElementsGet number of elements in data set
setElementChange element stored at specified index

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB documentation.

Examples

collapse all

Concatenate Dataset ds1 to Dataset ds

Convert data from two To Workspace blocks, convert to Dataset format, and concatenate them. myvdp is the vdp model with two To Workspace blocks with variables named simout and simout1. These blocks log data in time-series format.

mdl = 'myvdp';
open_system(mdl);
sim(mdl)
ds = Simulink.SimulationData.Dataset(simout);
ds1 = Simulink.SimulationData.Dataset(simout1);
dsfinal = concat(ds,ds1)

Related Examples

Introduced in R2011a

Was this topic helpful?