mdfDatastore
Datastore for collection of MDF files
Description
Use the MDF datastore object to access data from a collection of MDF files.
Creation
Description
creates an MDFDatastore based on an MDF file or a collection of files in the folder
specified by mdfds
= mdfDatastore(location
)location
. All files in the folder with extensions
.mdf
, .dat
, or .mf4
are
included.
specifies function options and properties of mdfds
= mdfDatastore(__,Name=Value
,Name=Value
,...)mdfds
using optional
name-value pairs.
Input Arguments
location
— Location of MDF datastore files
string | character vector | cell array | DsFileSet
object
Location of MDF datastore files, specified as a string, character vector, cell array, or object.
DsFileSet
object — You can specify aDsFileSet
object. For more information, seematlab.io.datastore.DsFileSet
.FileSet
object — You can specifylocation
as aFileSet
object. Specifying the location as aFileSet
object leads to a faster construction time for datastores compared to specifying a path orDsFileSet
object. For more information, seematlab.io.datastore.FileSet
.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*
. Iflocation
specifies a folder, by default the datastore includes all files in that folder with the extensions.mdf
,.dat
, or.mf4
. You can use theFileExtensions
parameter to limit or expand this list.The
location
as a file path can take one of these forms.Data Location
Form
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:scheme
://path_to_location
Based on the remote location,
can be one of the values in this table.scheme
Remote Location scheme
Amazon S3™ s3
Windows Azure® Blob Storage wasb
,wasbs
HDFS™ hdfs
For more information, see Work with Remote Data.
Example:
"s3://bucketname/path_to_file/myMdfData/"
Data Types: string
| char
| cell
| DsFileSet
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"
IncludeSubfolders
— Include files in subfolders
false
(default) | true
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
FileExtensions
— Custom extensions for filenames to include in MDF datastore
[".mdf",".dat",".mf4"]
(default) | string | char | cell
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
Properties
ChannelGroups
— All channel groups present in first MDF file
table
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
Channels
— All channels present in first MDF file
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
— Files included in datastore
char | string | cell
Files included in the datastore, specified as a character vector, string, or cell array.
Example: ["file1.mf4","file2.mf4"]
Data Types: char
| string
| cell
ReadRaw
— Read raw data values
false
(default) | true
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
ReadSize
— Size of data returned by read
"file"
(default) | numeric | duration
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
SelectedChannelGroupNumber
— Channel group to read
numeric scalar
Channel group to read, specified as a numeric scalar value.
Example: 1
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
SelectedChannelNames
— Names of channels to read
string | char | cell
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
read | Read data in MDF datastore |
readall | Read all data in MDF datastore |
preview | Subset of data from MDF datastore |
reset | Reset MDF datastore to initial state |
hasdata | Determine if data is available to read from MDF datastore |
partition | Partition MDF datastore |
numpartitions | Number 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 |
Examples
Create an MDF Datastore
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); end
Version History
Introduced in R2017bR2023b: Conversion Argument Pair Removed
Because of the new mdfRead
workflow underlying the
mdfDatastore
functionality, the Conversion
name-value pair argument is no longer supported. Code that uses this option generates an
error. Instead, you can use the ReadRaw
property and name-value
argument.
Minor corresponding updates of data types and formats are also made to the
ReadSize
, Channels
,
ChannelGroups
, and SelectedChannelNames
properties.
R2023a: Support for Remote File URLs
You can directly access MDF file data stored at remote locations, including Amazon S3, Azure® Blob Storage, and HDFS.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)