This example shows you how to open MDF files and access information about the file and its contents.
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("CANapeBasic.MF4")
m = MDF with properties: File Details Name: 'CANapeBasic.MF4' Path: '\\central-mi\home\michellw\Documents\MATLAB\Examples\vnt-ex51113426\CANapeBasic.MF4' 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.000010630 Creator Details ProgramIdentifier: 'MCD14.02' Creator: [1×1 struct] File Contents Attachment: [0×1 struct] ChannelNames: {2×1 cell} ChannelGroup: [1×2 struct]
Information about the originating tool of the MDF file is found in the Creator
property.
m.Creator
ans = struct with fields: VendorName: 'Vector Informatik GmbH' ToolName: 'CANape' ToolVersion: '14.0.20.2386' UserName: 'visosr' Comment: 'created'
Data in an MDF file is stored in channels contained within channel groups. This sample file contains two channel groups.
m.ChannelGroup(1) m.ChannelGroup(2)
ans = struct with fields: AcquisitionName: '10 ms' Comment: '10 ms' NumSamples: 1993 DataSize: 153461 Sorted: 1 Channel: [74×1 struct] ans = struct with fields: AcquisitionName: '100ms' Comment: '100ms' NumSamples: 199 DataSize: 23084 Sorted: 1 Channel: [46×1 struct]
Within a channel group, details about each channel are stored.
m.ChannelGroup(1).Channel(1)
ans = struct with fields: Name: 'Counter_B4' DisplayName: '' ExtendedNamePrefix: 'XCPsim' Description: 'Single bit demo signal (bit from a byte shifting)' Comment: 'Single bit demo signal (bit from a byte shifting)' Unit: '' Type: FixedLength DataType: IntegerUnsignedLittleEndian NumBits: 1 ComponentType: None CompositionType: None
The ChannelNames
property allows quick access to find specific channels within the various channel groups.
m.ChannelNames m.ChannelNames{1}
ans = 2×1 cell array {74×1 cell} {46×1 cell} ans = 74×1 cell array {'Counter_B4' } {'Counter_B5' } {'Counter_B6' } {'Counter_B7' } {'PWM' } {'PWM_Level' } {'PWMFiltered' } {'Triangle' } {'map1_8_8_uc_measure[0][0]'} {'map1_8_8_uc_measure[0][1]'} {'map1_8_8_uc_measure[0][2]'} {'map1_8_8_uc_measure[0][3]'} {'map1_8_8_uc_measure[0][4]'} {'map1_8_8_uc_measure[0][5]'} {'map1_8_8_uc_measure[0][6]'} {'map1_8_8_uc_measure[0][7]'} {'map1_8_8_uc_measure[1][0]'} {'map1_8_8_uc_measure[1][1]'} {'map1_8_8_uc_measure[1][2]'} {'map1_8_8_uc_measure[1][3]'} {'map1_8_8_uc_measure[1][4]'} {'map1_8_8_uc_measure[1][5]'} {'map1_8_8_uc_measure[1][6]'} {'map1_8_8_uc_measure[1][7]'} {'map1_8_8_uc_measure[2][0]'} {'map1_8_8_uc_measure[2][1]'} {'map1_8_8_uc_measure[2][2]'} {'map1_8_8_uc_measure[2][3]'} {'map1_8_8_uc_measure[2][4]'} {'map1_8_8_uc_measure[2][5]'} {'map1_8_8_uc_measure[2][6]'} {'map1_8_8_uc_measure[2][7]'} {'map1_8_8_uc_measure[3][0]'} {'map1_8_8_uc_measure[3][1]'} {'map1_8_8_uc_measure[3][2]'} {'map1_8_8_uc_measure[3][3]'} {'map1_8_8_uc_measure[3][4]'} {'map1_8_8_uc_measure[3][5]'} {'map1_8_8_uc_measure[3][6]'} {'map1_8_8_uc_measure[3][7]'} {'map1_8_8_uc_measure[4][0]'} {'map1_8_8_uc_measure[4][1]'} {'map1_8_8_uc_measure[4][2]'} {'map1_8_8_uc_measure[4][3]'} {'map1_8_8_uc_measure[4][4]'} {'map1_8_8_uc_measure[4][5]'} {'map1_8_8_uc_measure[4][6]'} {'map1_8_8_uc_measure[4][7]'} {'map1_8_8_uc_measure[5][0]'} {'map1_8_8_uc_measure[5][1]'} {'map1_8_8_uc_measure[5][2]'} {'map1_8_8_uc_measure[5][3]'} {'map1_8_8_uc_measure[5][4]'} {'map1_8_8_uc_measure[5][5]'} {'map1_8_8_uc_measure[5][6]'} {'map1_8_8_uc_measure[5][7]'} {'map1_8_8_uc_measure[6][0]'} {'map1_8_8_uc_measure[6][1]'} {'map1_8_8_uc_measure[6][2]'} {'map1_8_8_uc_measure[6][3]'} {'map1_8_8_uc_measure[6][4]'} {'map1_8_8_uc_measure[6][5]'} {'map1_8_8_uc_measure[6][6]'} {'map1_8_8_uc_measure[6][7]'} {'map1_8_8_uc_measure[7][0]'} {'map1_8_8_uc_measure[7][1]'} {'map1_8_8_uc_measure[7][2]'} {'map1_8_8_uc_measure[7][3]'} {'map1_8_8_uc_measure[7][4]'} {'map1_8_8_uc_measure[7][5]'} {'map1_8_8_uc_measure[7][6]'} {'map1_8_8_uc_measure[7][7]'} {'map1_8_8_uc_measure' } {'t' }
The channelList
function is available to quickly and easily query for channel details within an MDF file. It returns a case-insensitive, partial match to the provided input by default, but an exact match can also be used.
channelList(m, "PWM") channelList(m, "PWM", "ExactMatch", true)
ans = 3×9 table ChannelName ChannelGroupNumber ChannelGroupNumSamples ChannelGroupAcquisitionName ChannelGroupComment ChannelDisplayName ChannelUnit ChannelComment ChannelDescription _____________ __________________ ______________________ ___________________________ ___________________ __________________ ___________ ______________________________________________ ________________________________________________ "PWM" 1 1993 10 ms 10 ms "" <undefined> Pulse width signal from PWM_level and Triangle "Pulse width signal from PWM_level and Triangle" "PWM_Level" 1 1993 10 ms 10 ms "" <undefined> <undefined> "" "PWMFiltered" 1 1993 10 ms 10 ms "" <undefined> Low pass filtered PWM signal "Low pass filtered PWM signal" ans = 1×9 table ChannelName ChannelGroupNumber ChannelGroupNumSamples ChannelGroupAcquisitionName ChannelGroupComment ChannelDisplayName ChannelUnit ChannelComment ChannelDescription ___________ __________________ ______________________ ___________________________ ___________________ __________________ ___________ ______________________________________________ ________________________________________________ "PWM" 1 1993 10 ms 10 ms "" <undefined> Pulse width signal from PWM_level and Triangle "Pulse width signal from PWM_level and Triangle"