Main Content


Datastore for collection of MDF files


Use the MDF datastore object to access data from a collection of MDF files.




mdfds = mdfDatastore(location) creates an MDFDatastore based on an MDF file or a collection of files in the folder specified by location. All files in the folder with extensions .mdf, .dat, or .mf4 are included.

mdfds = mdfDatastore(__,Name=Value,Name=Value,...) specifies function options and properties of mdfds using optional name-value pairs.

Input Arguments

expand all

Location of MDF datastore files, specified as a string, character vector, cell array, or object.

  • DsFileSet object — You can specify a DsFileSet object. For more information, see

  • FileSet object — You can specify location as a FileSet object. Specifying the location as a FileSet object leads to a faster construction time for datastores compared to specifying a path or DsFileSet object. For more information, see

  • File path — You can specify a single file path as a character vector or string scalar. You can specify multiple file paths as a cell array of character vectors or a string array.

    The path can be relative or absolute, or a URL to a remote server. The location argument can contain the wildcard character *. If location specifies a folder, by default the datastore includes all files in that folder with the extensions .mdf, .dat, or .mf4. You can use the FileExtensions parameter to limit or expand this list.

    The location as a file path can take one of these forms.

    Data Location


    Current folder or MATLAB® path

    To access files in the current folder or MATLAB path, specify the name of the files or folder in location. Include the extension when specifying files.

    Example: ["myFile2.mf4","myFile3.mf4"]

    Example: "myDataFolder"

    Other folders

    To access files in a folder other than the current folder, specify the full or relative path name in location.

    Example: "C:\myFolder\myFile*.mf4"

    Example: "\myDataFolder"

    Remote location

    To access files in a remote location, location must contain the full path of the files or folder specified as a uniform resource locator (URL) of the form:


    Based on the remote location, scheme can be one of the values in this table.

    Remote Locationscheme
    Amazon S3™s3
    Windows Azure® Blob Storagewasb, wasbs

    For more information, see Work with Remote Data.

    Example: "s3://bucketname/path_to_file/myMdfData/"

Data Types: string | char | cell | DsFileSet

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

These pairs set file information or object Properties. Allowed options are IncludeSubfolders, FileExtensions, and the properties ReadRaw, ReadSize, SelectedChannelGroupNumber, and SelectedChannelNames.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: SelectedChannelNames="Counter_B4"

Include files in subfolders, specified as a logical. Specify true to include files in each folder and recursively in subfolders.

Example: IncludeSubfolders=true

Data Types: logical

Custom extensions for filenames to include in the MDF datastore, specified as a string, string array, character vector, or cell array of character vectors. By default, the supported extensions include .mdf, .dat, and .mf4. If your files have custom or nonstandard extensions, use this Name-Value setting to include files with those extensions.

Example: FileExtensions=[".myformat1",".myformat2"]

Data Types: char | cell


expand all

This property is read-only.

All channel groups present in first MDF file, returned as a table of the same format returned by the mdfChannelGroupInfo (Vehicle Network Toolbox) function.

Data Types: table

This property is read-only.

All channels present in first MDF file, returned as a table of the same format returned by the mdfChannelInfo (Vehicle Network Toolbox) function.

Those channels targeted for reading must have the same name and belong to the same channel group in each file of the MDF datastore.

Data Types: table

Files included in the datastore, specified as a character vector, string, or cell array.

Example: ["file1.mf4","file2.mf4"]

Data Types: char | string | cell

Read raw data values, specified as true or false. If specified true, data are read as raw values. If specified false, data are read as physical values. The default value is false.

Example: ReadRaw=true

Data Types: logical

Size of data returned by the read function, specified as "file", a numeric value, or a duration. A string value of "file" causes the entire file to be read; a numeric double value specifies the number of records to read; and a duration value specifies a time range to read.

If you later change the ReadSize property value type, the datastore resets.

Example: 50

Data Types: double | string | char | duration

Channel group to read, specified as a numeric scalar value.

Example: 1

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Names of channels to read, specified as a string, string array, character vector, or cell array.

Those channels targeted for reading must have the same name and belong to the same channel group in each file of the MDF datastore. Unless specified otherwise, the default value is the channel names in channel group 1 sorted in alphabetical order.

Example: "Counter_B4"

Data Types: char | string | cell

Object Functions

readRead data in MDF datastore
readallRead all data in MDF datastore
previewSubset of data from MDF datastore
resetReset MDF datastore to initial state
hasdataDetermine if data is available to read from MDF datastore
partitionPartition MDF datastore
numpartitionsNumber of partitions for MDF datastore
combine (MATLAB)Combine data from multiple datastores
transform (MATLAB)Transform datastore
isPartitionable (MATLAB)Determine whether datastore is partitionable
isShuffleable (MATLAB)Determine whether datastore is shuffleable


collapse all

Create an MDF datastore from the sample file CANape.MF4, and read it into a timetable.

mdfds = mdfDatastore("C:\myMDFData\CANape.MF4");
while hasdata(mdfds)
    m = read(mdfds);

Version History

Introduced in R2017b

expand all