Main Content

mdfWrite

Write timetable data to MDF file

Since R2022a

    Description

    example

    mdfWrite(mdfFileName,mdfData) writes a timetable of MDF data to a new channel group appended at the end of the specified MDF file. The timetable can also contain channel group and channel metadata, which you can add using the function mdfAddChannelGroupMetadata before performing the write operation. If the file does not exist, the function creates it.

    mdfWrite(mdfFileName,mdfData,GroupNumber=chanGrpNum) writes data to the specified channel group index. If unspecified, data is written to a new channel group appended to the end of existing channel groups.

    Examples

    collapse all

    Write data from a timetable to a specific channel group index in an MDF file.

    mdfWrite("MDFFile.mf4",mdfDataTT,GroupNumber=1)

    Input Arguments

    collapse all

    MDF file name to write to, specified as a string or character vector. The file name can be a relative or absolute path. The name must include the extension .dat, .mdf, or .mf4. If the file does not exist, the function creates it.

    Depending on the location you are accessing, mdfFileName can take one of these forms.

    Location

    Form

    Current folder or MATLAB® path

    To access a file in the current folder or MATLAB path, specify the name of the file in filename, including the file extension.

    Example: "myMdfFile.mf4"

    Other folders

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

    Example: "C:\myFolder\myMdfFile.mf4"

    Example: "\dataDir\myMdfFile.mf4"

    Remote locations

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

    scheme://path_to_file/myMdfFile.mf4

    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
    HDFS™hdfs

    For more information, see Work with Remote Data.

    Example: "s3://bucketname/path_to_file/myMdfFile.mf4"

    Example: "MDF_25Dec.mf4"

    Data Types: char | string

    Data, specified as a timetable, to write to the MDF file. The supported value data types in the timetable are int8, int16, int32, int64, uint8, uint16, uint32, uint64, single, double, string, and cell.

    Data Types: timetable

    Limitations

    • The mdfWrite function does not support writing array channels or structure channels.

    • When overwriting an existing channel, use a timetable that was created by the mdfRead function with the option IncludeMetadata=true. Do not remove any timetable custom properties returned by the mdfRead function.

    • When overwriting an existing channel, the ChannelReadOption property in the timetable custom properties is used internally to keep track of the kind of conversion rule applied during the read. Do not modify this custom property in the timetable.

    • When writing a new channel to an MDF file, the mdfWrite function does not support writing data with conversion rules. Only raw values can be written to new channels.

    • Boolean is not a supported data type in the MDF standard, so mdfWrite does not support the logical data type. To work around this limitation, convert the logical variable to an int8 or uint8 data type before writing to the MDF file.

    Version History

    Introduced in R2022a

    expand all