MATLAB Examples

Access MDF Files

This example shows you how to open MDF files and access information about the file and its contents.


Open an MDF File

Open an MDF file by specifying the name of the target file. Many basic details about the file are provided. This sample file was created using Vector CANape.

m = mdf('CANape.MF4')
m = 

  MDF with properties:

   File Details
                 Name: 'CANape.MF4'
                 Path: '\\central-mi\home\jpyle\Documents\MATLAB\examples\...'
               Author: 'Otmar Schneider'
           Department: 'PMC @ Vector Informatik GmbH'
              Project: 'Demo'
              Subject: 'XCPSim'
              Comment: 'Example file created with Vector CANape'
              Version: '4.10'
             DataSize: 176545
     InitialTimestamp: 2016-04-21 14:27:17

   Creator Details
    ProgramIdentifier: 'MCD14.02'
              Creator: [1×1 struct]

   File Contents
           Attachment: [0×0 struct]
         ChannelNames: {2×1 cell}
         ChannelGroup: [1×2 struct]

View File Creation Details

Information about the originating tool of the MDF file is found in the Creator property.

ans = 

  struct with fields:

     VendorName: 'Vector Informatik GmbH'
       ToolName: 'CANape'
    ToolVersion: ''
       UserName: 'visosr'
        Comment: ''

View Channel Group Details

Data in an MDF file is stored in channels contained within channel groups. This sample file contains two channel groups.

ans = 

  struct with fields:

    AcquisitionName: '10 ms'
            Comment: ''
         NumSamples: 1993
           DataSize: 153461
             Sorted: 1
            Channel: [1×74 struct]

ans = 

  struct with fields:

    AcquisitionName: '100ms'
            Comment: ''
         NumSamples: 199
           DataSize: 23084
             Sorted: 1
            Channel: [1×46 struct]

View Channel Details

Within a channel group, details about each channel are stored.

ans = 

  struct with fields:

                  Name: 'Counter_B4'
           DisplayName: ''
    ExtendedNamePrefix: 'XCPsim'
           Description: 'Single bit demo signal (bit from a byte shifting)'
               Comment: ''
                  Unit: ''
                  Type: FixedLength
              DataType: IntegerUnsignedLittleEndian
               NumBits: 1
         ComponentType: None
       CompositionType: None

Quickly Access Channels Names

The ChannelNames property allows quick access to find specific channels within the various channel groups.

ans =

  2×1 cell array

    {74×1 cell}
    {46×1 cell}

ans =

  74×1 cell array