Main Content

Dataset Conversion for Logged Data

Why Convert to Dataset Format?

You can use theSimulink.SimulationData.Datasetconstructor to convert a MATLAB®workspace variable that contains data that was logged in one of these formats toDatasetformat:

  • Array

  • Structure

  • 结构with time

  • MATLAB timeseries

  • ModelDataLogs

Converting data from other Simulink®logging formats toDatasetformat simplifies writing scripts to post-process data logged. For example, a model with multipleTo Workspaceblocks can use different data formats. Converting the logged data toDatasetformat 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 toDatasetformat also makes it easier to take advantage of features that requireDatasetformat. You can easily convert data logged in earlier releases that used a format other thanDatasetto work well withDatasetdata in a more recent release.

TheDatasetformat:

  • Uses MATLABtimeseriesobjects 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 resultingDatasetobject uses the variable name as its name. You can use a name-value pair to specify aDatasetname.

You can use theconcatmethod to combineDatasetobjects into one concatenatedDatasetobject.

Results of Conversion

Datasetobjects hold data as elements. To display the elements of aDatasetvariable, enter the variable name at the MATLAB command prompt. The elements ofDatasetobjects are different types, depending on the data they store. For example, signal logging stores data asSimulink.SimulationData.Signalelements and state logging inDatasetformat stores data asSimulink.SimulationData.Stateelements. 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.

Format Conversion Result Notes

MATLAB time series

If you log nonbus data, during conversion, the software first adds the data as aSimulink.SimulationData.Signalobject. It then adds that object as an element of the newly createdDataset.

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 aSimulink.SimulationData.Signalobject. It then adds that object as an element of the data set.

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 inDatasetformat. However, before converting structure and structure with time formats, the data structure must havetimeandsignalsfields.

Conversion populates aSimulink.SimulationData.Signalobject with the structure and adds it as an element of the data set. If other information is available, converting also adds it to the element or time-series values. For example, if the structure has a field calledblockName, converting adds it to the block path. Otherwise, the block path is empty.

When scope data is logged in structure format, the logged structure has aPlotStylefield. The software uses this field to set the interpolation in theDatasetobject.

Array

Arrays contain little information. For example, there is no block path information.

Conversion adds the array to aSimulink.SimulationData.Signalobject and adds it as an element of theDatasetobject. The conversion leaves unavailable information such as block path and timestamp fields as either empty or with default values.

ModelDataLogs

Converts data fromModelDataLogsformat toDatasetformat.

Note

TheModelDataLogsformat is no longer used for signal logging.

Dataset Conversion Limitations

  • Converting logged data toDatasetformat results in aDataset对象包含的所有信息that the original logged data included. However, if there is no corresponding information for the otherDatasetproperties, the conversion uses default values for that information.

  • When you convert data for a variable-size signal logged using theTo Workspaceblock, the information in thevalueDimensionsfield 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 toDataset,Datasetpreserves that organization. But if you log the bus signal inDatasetformat 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 toDataset,conversion inserts a time vector. There is one time step for each data value. However, the simulation time steps and theDatasettime steps can vary.

  • Datasetformat ignores the specification of frame signals. Conversion of structure or structure with time data toDatasetreshapes the data for logged frame signals.

See Also

Related Topics