Main Content

mdfCreate

Create MDF file with metadata

Since R2022a

    Description

    example

    mdfCreate(mdfFileName) creates an MDF file at the location specified by mdfFileName, using default file metadata. The file name must include the extension .dat, .mdf, or .mf4. mdfFileName can specify an absolute or full path, or a URL for a file on a remote server.

    example

    mdfCreate(mdfFileName,FileInfo=mdfInfoObj) creates an MDF file using the specified metadata to configure during file creation. The object mdfInfoObj must be of the form returned by the mdfInfo (Vehicle Network Toolbox) function, which you can use to create the object and then modify it as needed. The supported values for the mdfInfoObj.Version property are "3.00", "3.10", "3.20", "3.30", "4.00", "4.10", and "4.20".

    newMDFFile = mdfCreate(___) creates an MDF file and returns its full path name as a string to the variable newMDFFile. The returned full path can be useful when specifying a partial or relative path to create the file.

    Examples

    collapse all

    Create a new MDF file, and view its metadata.

    mdfCreate("MDF_25Dec.mf4")
    ans = 
    
        "C:\data\mdf\MDF_25Dec.mf4"
    mdfInfo("MDF_25Dec.mf4")
    ans = 
    
      MDFInfo with properties:
    
       File Details
                      Name: "MDF_25Dec.mf4"
                      Path: "C:\data\mdf\MDF_25Dec.mf4"
                    Author: ""
                Department: ""
                   Project: ""
                   Subject: ""
                   Comment: ""
                   Version: "4.20"
          InitialTimestamp: 2022-10-20 18:39:41.000000000
    
       Creator Details
         ProgramIdentifier: "MATLAB"
         CreatorVendorName: "The MathWorks, Inc."
           CreatorToolName: "MATLAB"
        CreatorToolVersion: "9.14.0.2081372 (R2023a)"
           CreatorUserName: ""
            CreatorComment: ""
    
       File Contents
                Attachment: [0×8 table]
         ChannelGroupCount: 0

    Create a new MDF file with modified metadata.

    Create a default information object, set its properties, and make a new MDF file.

    minfo = mdfInfo;
    minfo.Comment = "25-Dec Shift B.";
    minfo.Version = "4.10";
    %   ⋮
    % Modify other properites as needed.
    %   ⋮
    mdfCreate("MyMDFfile.mf4",FileInfo=minfo);

    Create a new MDF file with metadata taken from an existing file.

    minfo = mdfInfo("MyMDFfile1.mf4");  % Existing MDF file.
    info.Version = "4.10";
    createdFilePath = mdfCreate("MyMDFfile2.mf4", FileInfo=info) % New file, with matadata from existing file.

    Input Arguments

    collapse all

    MDF file name to create, 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.

    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

    Output Arguments

    collapse all

    Full path name of the newly created MDF file, returned as a string.

    Limitations

    • mdfCreate does not support adding custom file metadata fields.

    Version History

    Introduced in R2022a

    expand all