Documentation Center

  • Trial Software
  • Product Updates


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


convertedDataset = sourceModelDataLogsObject.convertToDataset(convertedDatasetName)


    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.


Source of Simulink.ModelDataLogs Logged DataConversion Limitation

Referenced model

Loads all ancestors of the referenced model not previously loaded. If any ancestor model does appear not 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 activeas 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


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


Name of the dataset that the conversion process creates.

Output Arguments


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

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


Log signal data, simulate the model, and then convert the logged dataset to the Simulink.SimulationData.Dataset format.

  1. Open the vdp model by typing:

  2. Right-click the x1 and x2 signals.

  3. Click the Record button arrow and click Log/Unlog Selected Signals.

  4. Simulate the model.

    The vdp model has the Configuration Parameters > Data Import/Export > Signal logging parameter selected, and the signal logging object name set to logsout. Also, the Signal Logging Format parameter is set to ModelDataLogs.

    Simulink generates a warning about the use of the ModelDataLogs format.

  5. At the MATLAB command line, type:

    logsout =
    Simulink.ModelDataLogs (vdp):
      Name                   Elements  Simulink Class
      x1                        1      Timeseries
      x2                        1      Timeseries
  6. Convert the logged dataset to use the Simulink.SimulationDataset format:

    dataset = logsout.convertToDataset('vdp_dataset')
    dataset = 
      Package: Simulink.SimulationData
                  Name: 'vdp_dataset'
        Total Elements: 2
        1: 'x1'
        2: 'x2'
      Use getElement to access elements by index, name or block path.
      Methods, Superclasses

See Also

| |

Was this topic helpful?