Main Content

Simulink.io.MDF Class

Namespace: Simulink.io

Read data in MDF-file format

Since R2023b

Description

The Simulink.io.MDF class inherits from the Simulink.io.FileType base class. The class reads data formatted in a format used by measurement data format (MDF) files. To import data from an MDF-file, use this class.

Note

The Simulink.io.MDF class requires a Vehicle Network Toolbox™ or Powertrain Blockset™ license.

classdef MDF < Simulink.io.FileType

The Simulink.io.MDF class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

fileType = Simulink.io.MDF('MDFfile.mdf') creates an MDF-file reader.

fileType.FileName = Simulink.io.MDF('MDFfile.mdf') assigns a string or character array representing the MDF-file name.

example

Input Arguments

expand all

File name of MDF-file, specified as a character vector.

Output Arguments

expand all

File type of reader, returned as a character vector.

Properties

expand all

File name of file that contains MDF-file signals for import to Signal Editor, specified as a character array.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Methods

expand all

Protected Methods

Examples

collapse all

Read MDF-file format from a channel group number using the readDatasetFromGroupNumber function.

Create a file path.

filePath = fullfile(pwd,'dataSetMdf.mdf');

Create multiple data sets.

ds = Simulink.SimulationData.Dataset;
ds = ds.addElement( timetable(seconds([1;2]),[1;2]),'X');
ds = ds.addElement( timetable(seconds([1;2]),[1;2]),'Y');
ds = ds.addElement( timetable(seconds([1;2]),[1;2]),'Z');

Export the data sets to MDF format.

anMDF_FileType = Simulink.io.MDF;
anMDF_FileType.export( filePath, {'group1' 'group2'},{ds ds},0)
anMDF_FileType.export( filePath, {'group1' 'group2'},{ds ds},0)

Version History

Introduced in R2023b