You can use the
constructor to convert a MATLAB® workspace variable that contains data that was logged in one of these formats
to Simulink.SimulationData.Dataset
Dataset
format:
Array
Structure
Structure with time
MATLAB timeseries
ModelDataLogs
Converting data from other Simulink® logging formats to Dataset
format simplifies
writing scripts to post-process data logged. For example, a model with multiple To
Workspace blocks can use different data formats. Converting the logged data to
Dataset
format avoids the need to write special code to handle
different formats.
Different simulation modes have different levels of support for data logging formats. Switching between normal and accelerator modes can require changes to the logging formats used.
The conversion to Dataset
format also makes it easier to
take advantage of features that require Dataset
format. You can
easily convert data logged in earlier releases that used a format other
than Dataset
to work well
with Dataset
data in a more recent release.
The Dataset
format:
Uses MATLAB
timeseries
objects to store logged data,
which allows you to work with logging data in MATLAB without a Simulink license. For example, to manipulate the logged data, you can use
MATLAB time-series methods such as filter
,
detrend
, and resample
.
Supports logging multiple data values for a given time step, which is important for Iterator subsystem and Stateflow® signal logging.
By default, the resulting Dataset
object uses the variable name as
its name. You can use a name-value pair to specify a Dataset
name.
You can use the concat
method to
combine Dataset
objects into one
concatenated Dataset
object.
Dataset
objects hold data as elements. To display the elements of a
Dataset
variable, enter the variable name at the MATLAB command prompt. The elements of Dataset
objects are
different types, depending on the data they store. For example, signal logging stores data
as
elements and state
logging in Simulink.SimulationData.Signal
Dataset
format stores data as
elements. Each
element holds data as a MATLAB time-series object. At conversion, the elements and time-series field populate
as much as possible from the converted object.Simulink.SimulationData.State
Format | Conversion Result Notes |
---|---|
MATLAB time series | If you log nonbus data, during conversion, the software first adds the
data as a If you log bus data in time-series
format, one time series corresponds to each element of a bus. Converting arranges
the logged data as a structure with time-series objects as leaf nodes. This
structure hierarchy matches the bus hierarchy. Conversion of this type of
structure of time-series objects adds the whole structure to a
Time-series objects hold relevant information such as block path and timestamps. The conversion tries to preserve this information. |
Structure and structure with time | Structure and structure with time formats do not always contain as much
information as if you log in Conversion populates a
When scope data is logged in
structure format, the logged structure has a |
Array | Arrays contain little information. For example, there is no block path information. Conversion adds the array to a
|
| Converts data from Note The |
Converting logged data to Dataset
format results in a
Dataset
object that contains all the information that the original
logged data included. However, if there is no corresponding information for the other
Dataset
properties, the conversion uses default values for that
information.
To log variable-size signals, use the To Workspace block. If you convert data logged with To Workspace to be
Dataset
format, you lose the information about the variable-size
signals.
When you log a bus signal in array, structure, or structure with time formats, the logged data is organized with:
The first column containing the data for the first signal in the bus
The second column containing data for the second bus signal, and so on
When you convert that data to Dataset
, the
Dataset
preserves that organization. But if you log the bus signal
in Dataset
format without conversion, the conversion captures the bus
data as a structure of time-series objects.
If the logged data does not include a time vector, when you convert that data to
Dataset
, the conversion inserts a time vector. There is one time
step for each data value. However, the simulation time steps and the
Dataset
time steps can vary.
Dataset
format ignores the specification of frame signals.
Conversion of structure or structure with time data to Dataset
reshapes the data for logged frame signals.
Simulink.SimulationData.Dataset