Simulink.ModelDataLogs.convertToDataset

Convert logging data from Simulink.ModelDataLogs format to Simulink.SimulationData.Dataset format

Syntax

convertedDataset = sourceModelDataLogsObject.convertToDataset(convertedDatasetName)

Description

    Note:   The ModelDataLogs format is supported for backwards compatibility. The ModelDataLogs format will be removed in a future release. For an existing model that uses the ModelDataLogs format, you should migrate the model to use Dataset format. For details, see Migrate from ModelDataLogs to Dataset Format.

    For new models, use the Dataset logging format, which stores logged data in Simulink.SimulationData.Dataset objects.

convertedDataset = sourceModelDataLogsObject.convertToDataset(convertedDatasetName) converts the 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.

Limitations

Source of Simulink.ModelDataLogs Logged DataConversion 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's ancestors have changed, after Simulink® logged the data, the conversion may 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 Simulink.SimulationData.Dataset object as the dataset than Simulink creates when you simulate the model using the Dataset format for the logged data .

Stateflow® chart

Not supported.

Input Arguments

sourceModelDataLogsObject

A Simulink.ModelDataLogs object that you want to convert to a Simulink.SimulationData.Dataset object.

convertedDatasetName

Name of the dataset that the conversion process creates.

Output Arguments

convertedDataset

The Simulink.SimulationDataset object that the Simulink.ModelDataLogs.convertToDataset function creates.

For details about the converted dataset, see Simulink.SimulationData.Dataset.

Example

If you have signal logging data from a model that has Configuration Parameters > Data Import/Export > Signal logging format set to ModelDataLogs format, you should change the logging format to Dataset. However, 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 theConfiguration Parameters > Data Import/Export > Signal logging name set to logsout.

  1. Load the MAT-file.

  2. 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
Was this topic helpful?