Dataset Conversion for Logged Data
Why Convert to Dataset Format?
You can use the
constructor to convert a MATLAB®workspace variable that contains data that was logged in one of these formats toSimulink.SimulationData.Dataset
Dataset
format:
Array
Structure
结构with time
MATLAB timeseries
ModelDataLogs
Converting data from other Simulink®logging formats toDataset
format simplifies writing scripts to post-process data logged. For example, a model with multipleTo Workspaceblocks can use different data formats. Converting the logged data toDataset
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 toDataset
format also makes it easier to take advantage of features that requireDataset
format. You can easily convert data logged in earlier releases that used a format other thanDataset
to work well withDataset
data in a more recent release.
TheDataset
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 asfilter
,detrend
, andresample
.Supports logging multiple data values for a given time step, which is important for Iterator subsystem and Stateflow®signal logging.
By default, the resultingDataset
object uses the variable name as its name. You can use a name-value pair to specify aDataset
name.
You can use theconcat
method to combineDataset
objects into one concatenatedDataset
object.
Results of Conversion
Dataset
objects hold data as elements. To display the elements of aDataset
variable, enter the variable name at the MATLAB command prompt. The elements ofDataset
objects are different types, depending on the data they store. For example, signal logging stores data as
elements and state logging inSimulink.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 |
Dataset Conversion Limitations
Converting logged data to
Dataset
format results in aDataset
对象包含的所有信息that the original logged data included. However, if there is no corresponding information for the otherDataset
properties, the conversion uses default values for that information.When you convert data for a variable-size signal logged using theTo Workspaceblock, the information in the
valueDimensions
field of the structure is lost in the conversion.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
,Dataset
preserves that organization. But if you log the bus signal inDataset
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
,conversion inserts a time vector. There is one time step for each data value. However, the simulation time steps and theDataset
time steps can vary.Dataset
format ignores the specification of frame signals. Conversion of structure or structure with time data toDataset
reshapes the data for logged frame signals.
See Also
Simulink.SimulationData.Dataset