Datastore for collection of MDF files


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



mdfds = mdfDatastore(location)
mdfds = mdfDatastore(__,'Name1',Value1,'Name2',Value2,...)



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(__,'Name1',Value1,'Name2',Value2,...) specifies function options and properties of mdfds using optional name-value pairs.

Input Arguments

expand all

Location of MDF datastore files, specified as a character vector, cell array of character vectors, or object identifying either files or folders. The path can be relative or absolute, and 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.

Example: 'CANape.MF4'

Data Types: char | cell | DsFileSet

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments to set file information or object Properties. Allowed options are IncludeSubfolders, FileExtensions, and the properties ReadSize, SelectedChannelGroupNumber, and SelectedChannelNames.

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 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

All channel groups present in first MDF file, returned as a table.

Data Types: table

All channels present in first MDF file, returned as a table.

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

Size of data returned by the read function, specified as 'file', a numeric value, or a duration. A character vector 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 | 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 character vector, string, or cell array.

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


collapse all

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

mdfds = mdfDatastore(fullfile(matlabroot,'examples','vnt','CANape.MF4'));
while hasdata(mdfds)
    m = read(mdfds);

Introduced in R2017b