Convert logging data from Simulink.ModelDataLogs
format
to Simulink.SimulationData.Dataset
format
convertedDataset
= sourceModelDataLogsObject
.convertToDataset(convertedDatasetName
)
Note
The ModelDataLogs
class is supported
for backwards compatibility. Starting in R2016a, you cannot log data
in the ModelDataLogs
format. Signal logging
uses the Dataset
format. In R2016a or later,
when you open a model from an earlier release that had used ModelDataLogs
format,
the model simulated in use Dataset
format.
You can convert signal logging data from ModelDataLogs
to Dataset
format.
Converting to Dataset
format makes it easier
to post-process with other logged data (for example, logged states),
which can also use Dataset
format. For
more information, see Convert Logged Data to Dataset Format.
If you have legacy code that uses the ModelDataLogs
API,
you can encounter situations that require updates to your code or
model. See Migrate Scripts That Use Legacy ModelDataLogs API.
converts
the convertedDataset
= sourceModelDataLogsObject
.convertToDataset(convertedDatasetName
)sourceModelDataLogsObject
to a Simulink.SimulationData.Dataset
object.
The name of the converted object is based on convertedDatasetName
.
The resulting Simulink.SimulationData.Dataset
object
is a flat list. This list has one element for each Simulink.Timeseries
or Simulink.TsArray
object
in the Simulink.ModelDataLogs
object.
Source of Simulink.ModelDataLogs Logged Data | Conversion Limitation |
---|---|
Referenced model | Loads all ancestors of the referenced model not previously loaded. If any ancestor model does not appear on the MATLAB® path, the conversion fails. If the model has changed, or the model ancestors have changed, after Simulink® logged the data, the conversion can fail. For example, adding, deleting, or renaming a block after logging can cause conversion failure. |
Variant model or subsystem | The current active variant must be the same one that was active when Simulink logged the data. Otherwise, the conversion fails. |
Frame signal | The conversion fails. |
Mux block | The conversion produces a different |
Stateflow® chart | Not supported. |
|
A |
|
Name of the dataset that the conversion process creates. |
|
The For details about the converted dataset, see |
In releases before R2016a, you could log signals using ModelDataLogs
format.
If you have a MAT-file with signal logging data that uses the ModelDataLogs
format,
here is how you can convert that data to Dataset
format.
This example assumes that the model that generated the logging data
had the Configuration Parameters > Data Import/Export > Signal
logging name set to logsout
.
Load the MAT-file.
Convert logsout
to a dataset called myModel_dataset
.
(The elements information will be different for your data.)
dataset = logsout.convertToDataset('myModel_Dataset') dataset = Simulink.SimulationData.Dataset Package: Simulink.SimulationData Characteristics: Name: 'myModel_Dataset' Total Elements: 2 Elements: 1: 'x1' 2: 'x2' -Use get or getElement to access elements by index or name. -Use addElement or setElement to add or modify elements. Methods, Superclasses
Simulink.ModelDataLogs
| Simulink.SimulationData.Dataset
| Simulink.SimulationData.updateDatasetFormatLogging