File Exchange

image thumbnail

MDF Import Tool and Function updated for mdf-file format from INCA 7.1.9

version 1.0.0.0 (38.1 KB) by Daniel F.
Import mdf files (.dat or .mdf) to the workspace or save as .mat file via commandline or GUI

61 Downloads

Updated 10 Apr 2018

View License

Since the original function provided by Stuart Mc Garrity is not maintained anymore, this version of his "MDF Import Tool and Function" just adds the support for the new data formula introduced with INCA 7.1.9.
Do not hesitate to contact me if something doesn't work.

Cite As

Daniel F. (2020). MDF Import Tool and Function updated for mdf-file format from INCA 7.1.9 (https://www.mathworks.com/matlabcentral/fileexchange/52952-mdf-import-tool-and-function-updated-for-mdf-file-format-from-inca-7-1-9), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (66)

claudio

Hi Daniel

good work! I have a question.. in my mdf file I have some variables that originally whose values are strings. so, using MDF import tool I can read numeric values but not the associated strings. how I can retrieve those strings?

I have a hew suggestions that I hope will be helpful. I am running this tool from the Matlab command window, and ultimately wanting to integrate the 'mdfimport' command into other scripts. It would be great if a third option was added where the data is imported to the calling function workspace instead of the base workspace. Also, it would be great if the 'mdfimport' command actually returned output, such as a list of the newly imported variable names (since they are different than the real signal names, as a result of rate suffixes).

Hi,
I am trying to convert the ADTF .dat file and .mdf file (recorded with CANoe) into csv file format so that i can extract the various signal easily. please let me know if this tool can do that and if yes, then i would really appreciate if you can guide me the procedure to do it.
Thanks

qrqr

mdf4読み込みたい

One of the channels in the mdf file is in string format but when it is processed into .mat the string value is converted into some random integer value. Is there a way to preserve the string format for that signal while .mdf file is being converted?

For people who have problem with files in mdf V4 format, have a look on this link: https://ci.appveyor.com/project/danielhrisca/asammdf/builds/26024260/job/aftx11l3njqc2ist/artifacts
This tool seems suitable to convert e.g. Vector mdf file in mdf V3.

Great update.
Finally I can use it with new INCA files.

qrqr

関数または変数 'D' が未定義です。
なぜこのエラーが出るのですか?

wenjun pan

Hello, I failed to import a mdf file by m command, but it's possible to load by GUI, why?
Could you take a look, what should i do?

mdfimport('E:\ARM\VW\MDF\mdf_D_10.mdf','Auto MAT-File');
'CNBlock' doesn't exist。

error mdfimport>mdfinfo (line 1430)
pos=zeros(length(CGBlockTemp.CNBlock),1);

erro mdfimport>parseparameters (line 2498)
[MDFsummary, options.MDFInfo, counts, channelList]=mdfinfo(options.fileName);

error: mdfimport (line 61)
options=parseparameters(varargin);

Christian

Any updates on mf4 support?

Sean Moch

I tried to use this tool but I am getting corruption of the data when read into matlab, some of the data are then incorrect.

MT_jsmith

Thank you very much!

Hello Daniel.
Thank you very much for this usefull update.
Even if I am now able to read new INCA files there is still some bugs for the files generated from MDA.
The time vector is sometimes not the same length as the data vector :-(

Ps: I don't know how can I send a sample to you.

Florian

Daniel F.

Hey masoom,

For your questions:
a. I have no idea, just give it a try.
b. No it doesn't, but u can write this function for yourself with the 'interp' function of Matlab :)

BR,
Daniel

Hello Daniel. I have two questions with respect to this tool

a. Does it work for MATLAB version 2012b
b. Does it have the function of re-sampling all the signals at a chosen raster (say .01 seconds) directory from the command line. The reason that I would like to resample is because the vectors are created with unequal lengths. This would create problems for me in plotting, computing unequal length vectors

I am using something like this to make a call to the function

clc
clear all
close all
readloc = 'C:\xyz.dat';
saveloc = strcat(readloc(1:length(readloc)-4), '_proc.mat');
signals = {'a' 'b' 'c' 'd'};
mdfimport(readloc, saveloc, signals, ideal);

Any help would be greatly appretiated

Thanks in advance

Best Regards
Masoom

Daniel F.

Hey jan, since you weren't the only one experiencing problems with the archive I just updated it. You could have tried using the windows zipping tool instead of 7zip. Nevertheless I just repacked it with 7zip and it should now work flawless.

Cheers, Daniel

Jan Kappen

Downloaded zip archive does only contain licence.txt

Mo Jay

Hello,

I do not receive the mdfimport function when downloading the file - just the licence? thank you.

Special_k

Or perhaps another solution could be adding an option in the drop down for not appending the variable names.

Special_k

Hey Daniel,

I'm trying to create my own data processing script that uses the mdfimport tool to bring my signals into the work space. The problem I am having is with the rate/number appending function as it changes the names of my work space variables every time I do not import the same number of variables or I change the rate I sample the data at.

Is there any way to remove this rate/number appending function from the tool?

Thanks

Daniel F.

Hey Richard,
I think this is possible - but as always it would be helpful to know where the error occurs and what causes it by having the file you are using. Can u provide a stripped file with a working and non-working channel in it?

Nice piece of work and certainly (almost) very useful for me. The issue I have is that I seem to have some channels which have strange bit lengths. I don't know what has caused this but it causes the script to abandon everything else from that point on. It would be great if the script could just ignore that suspect channel (maybe issue some warning) and then go on to the next channel. Do you think that is possible?

hi Daniel,
I am trying to read .dat file but it Keep showing me following error.
Reference to non-existent field 'DGBlock'.

Error in mdfimport>mdfchannelgroupinfo (line 1581)
fieldNames=fieldnames(MDFStructure.DGBlock(1).CGBlock(channelGroup).CNBlock);

Error in mdfimport>mdfinfo (line 1472)
[MDFsummary, channelList]=mdfchannelgroupinfo(MDFstructure);

Error in mdfimport>populate_GUI (line 410)
[MDFsummary, MDFInfo, counts, channelList]=mdfinfo(handles.fullFileName);

Error in mdfimport>Load_MDF_File_Callback (line 616)
handles=populate_GUI(handles); % Populate GUI (list box)

Error in gui_mainfcn (line 96)
feval(varargin{:});

Error in mdfimport (line 87)
gui_mainfcn(gui_State, varargin{:});

Error while evaluating uimenu Callback.

Please help out. All suggestions are welcome. thanks

Daniel,
Thanks for the quick reply. I'm using VECTOR files, and tweaked the code to meet my needs. Tweaks include:
Support for signal data type 9 and 10.
Use of fread with 5th parameter set to 'b'.
I'm not able to provide my code or test files, sorry.
Motorola byte order = big endian byte order, read more here https://en.wikipedia.org/wiki/Endianness
Bob

Daniel F.

Hey Bob,

Be remembered that I only fixed the file to support the new format introduced in INCA 7.1.9. The original file was created by someone else - see my credits for the original one.

I am not quite sure what you mean by the Motorola format. Are you recording CAN signals?
Do you have a snippet of the measurement file you were using so I could try it on my own?

BR
Daniel

Hi Daniel,

I'm also having trouble with Motorola (big endian) signal data import, I'm seeing error "Unsupported Signal Data Type" for signalDataType = 9. I'm running the latest version of your MDFimport tool.

Thanks,
Bob

Adam

Works very well for the most part. However, when selecting all the variables in the data file (more than 300), some variables are not imported for whatever reason. If I only select the variables in question, they are imported properly.

Daniel F.

Hey Mikael,

I'm sorry to hear that - but with Win10 stock Zip-File handling, I can see all files and also with 7zip version 9.20 I can see all the files.
A lot of people had this problem yet - I think I will reupload it again and zip it with WinRar. Meanwhile - can you give me some information which programs you've already tried?

@Jiho:
I do not fully understand when the error occured. Did you proceed as follows:
@Matlab - Command Windows: mdfimport
@MDF File Import -> MDF File -> Open MDF File
?
If so, what did you do afterwards or did the error occure when you clicked "Open MDF File"?

Thanks and BR,
Daniel

Jiho

Hi~ daniel.
first of all, thanks a lot for this tool.
I have some problem when I click the open file. please see the below.

mdfimport>Generate_Function_Call_1_Menu_Callback(line 937)
selectedChannelList=handles.selectedChannelList;%
gui_mainfcn(line 95)
feval(varargin{:});

mdfimport(line 87)
gui_mainfcn(gui_State, varargin{:});

menu callback didnt work.
How do I fix them?

Hi!

The zip contains only an empty license file. Have tried 7zip.

BR
Mikael

Daniel F.

hey yichao,

guess you tried to unzipp with Windows stock program? Can you try another zip program like 7zip?

Yichao Guo

Hi, Daniel. The zip file is broken.
Is it possible for you to re-upload it or email me? Thanks.

If I would like to have all the variables in one stuct instead of in the working space, how would you suggest is the best way to ashine this? Would it be to first use mdfimport and then read the variables from working space or is it better to make some minor change to the script?
Best regards
Thomas

Makou

Thank you Dennis, it's working perfectly with windows explorer !
Regards.

Dennis

For everyone who has trouble with the zip file. For me it worked when I opened it with windows explorer instead of 7zip.

Thanks for sharing a pretty awesome tool!
Tested with Matlab 2016b and INCA7.1.10.
However, my system contains many inconveniently long variable names; longer than the 'isvarname' function allows (namelengthmax = 63). This scenario is not handled in your current version and the script discards the variables with a warning message. Luckily, I was able to poke around in the 'mdfimport.m' and find the function 'mygenvarname' where it is suitable to insert test-and-modify conditions for my case!

Makou

Hello, I confirm, there is a bug with the zip file, it's empty

anyone know the differences between .MDF data created by INCA and MDF data create by Vector with CANalyzer or CANApe tools? Even if I set output in CANALYzer MDF2.0 (I've also tryed 3.0 3.2 and 4.0), I can only see the name of variables but I can't import them.

vlkjan2

hello Daniel. Can you send me your Matlab tool in zip file on my email janvlk2@gmail.com ? I can´t download it from here. It writes some errors in unzipping process.

Thank you.

Jan Vlk

Hello Daniel, I'm recording my data with ETAS INCA and I'm looking for a way, to import my signals to MATLAB.
At this point, the MDF import code doesn't work. Do I need a specific toolbox and license to run it?
And is there a description anywhere, how to use this file?
I would be really glad, if you can help me. Keep on,
Best regards

Julio M.

Hello Daniel,

first of all, thanks a lot for the tool and your support. I have been reading and struggling with the code in the subfunction "mdfchannelread", exactly on the section where the "skip" and "precisionString" are generated in order to finally read the Data linked to a channel. It seems that with variables from INCA where the values are "false" or "true", the function is not able to read them properly since it saves a "double" array with all values set to 0 (no matter if "true" or "false"). I have tried to change the "precisionString" to '*uchar' or any other combination, but the imported values are not useful (or I do not know how to use them). The same occurs with the Faults variables from the ECU. Is it possible to import variables with "text" Data stored?
Thanks in advance.
Regards,

Julio

Tamara A.

Hello Daniel,

data are recorded with ETAS ES420, but we only have Problems with data bigger than 2GB and variables related to temperature sensors, it´s a little bit strange actually. I didn't record the data myself, so I'm not sure about these multiple times possibility.
Regards,
Tamara

Daniel F.

Hello Tamara,

nice to hear so far ;)
What is the program you record your data with? Keep in mind that this tool aims for data recorded with ETAS INCA.
I myself read in files with around 3-4Gb and had now problem with it.

Maybe the problem results from having recorded one signal multiple times with different sample times - which I would not recommend at all.

The limit - I would assume - results from your OS (32/64Bit) and machines RAM.

Regards,
Daniel

Tamara A.

Hello Daniel,
I find this Tool great thanks! But I have some Problems with big data, some variables and its time-vectors are mixed-up. But it only occurs with big data. Is there like a maximum size the tool supports?
Thanks in advance!
Regards,
Tamara

Daniel F.

hey amith!
different sample times are no problem since there will be different time vectors for each sample time used.
To. sample up(interpolation) or down Matlab already as a function available: interp (I think).

hope this helps.

Amith

Hey Daniel,
is the tool capable to account for variables that have been sampled on different acquisition rates? Is there a way that I can upsample/ downsample them?

Junseok Lee

William

Hi Daniel,

Thanks for the tool! It has been very helpful. I do see that there is no current option for importing the signals including their accompanying units. I took a look at the code and found that you had commented out lines 1143 through 1155 which seem to pertain to adding in the units during import from MDF to the MATLAB Workspace.

As I am unfamiliar with the MDF format, are there any current plans that you have to add this functionality in at a later date?

Thanks again!

Hello Daniel,

Thank you Daniel for the updated MDF Import Function.

By using this function I am importing .dat to Matlab but importing time(Computational time) is very high. How can I reduce importing time?

For example : It is not so much big difference when I import all signals from one data (.dat) and 4 signals from same data.

Tank you in advance

Regards
Mani

Daniel F.

Hello Andy,

currently I do not have a Matlab 2015b (I use 2015a) version and up to now I didn't knew any incompatibility issues - so thanks for mentioning, I will check on that.

Resampling has been asked many times by now - I think I will provide a function that can be used after reading the MDF-file into Matlab. I already created that function - just let me refine the code and documentation.

Regards,
Daniel

Andy L

I am hoping to implement this function in some of my scripts as original function is incompatible with 2015b, however without resample I am forced to look elsewhere. Is this a feature you are planning on adding?

Daniel F.

Hello Seungwoo,

the root error is in line 83. The function "parseparameter" requires a ".dat" file NOT ".mdf". Please call the function as shown below.
mdfimport('filename.dat')

Keep in mind, that the file you want to read must be situated in any Matlab-Path.

Best regards,
Daniel

Hello Daniel,

I tried to open mdf file using this tool, but I got the error below.

Reference to non-existent field 'DGBlock'.

Error in mdfchannelgroupinfo (line 10)
fieldNames=fieldnames(MDFStructure.DGBlock(1).CGBlock(channelGroup).CNBlock);

Error in mdfinfo (line 279)
[MDFsummary, channelList]=mdfchannelgroupinfo(MDFstructure);

Error in parseparameters (line 20)
[MDFsummary, options.MDFInfo, counts,
channelList]=mdfinfo(options.fileName);

Error in importMDF3 (line 83)
options = parseparameters(varargin);

I only used the command "importMDF3('filename.mdf')". Do you have any idea what my error messages are?

Hello Julian,
do you know if exists an mdfimport version that works with files mdf 4.0?
Thank you very much!
Giuseppe

Daniel F.

Hey Julian,

if I got you right, the information below should help you to get what you want. If you're not into Matlab right now do not hesitate to contact me =)

It should be possible to receive the signals with some code modifications, but I would recommend you to put it in a separate function.
According to some debugging I've done you can use parts of the included functions:
1. "Load_MDF_File_Callback" (line 602).
2. "populate_GUI" (beginning from line 408)

and that's it.
Notice: The functions I told you might be using additional functions within "mdfread" so you might have to include them in the new function too.

Hope that helps.

Best regards,
Daniel

Julian

Hi Daniel,

I had a quick question for you, that I just posted on the orig mdfimport page: Is there a way to query the mdf file, prior to loading in the data, to get a list of signals available? Is this something that can be achieved with some quick modifications to the code? It would be very helpful if possible, especially when dealing with 500 MB files!

Thanks,
Julian

Jared Lee

Daniel,

Very awesome tool. One quick question: is there a way to account for variables that have been sampled on different raster rates? Is there a way that I can force all of the signals on to the slowest or fastest sampled rate?

Sean

Worked well. Thanks.

Daniel F.

Good morning Xiaowei,

no problem and have fun with it ;)

Regards,
Daniel

Xiaowei Ng

Hey Daniel,
I was mistaken, It did work! But I'm glad you pointed me to where in the code things were changed.
Thank you again!
Regards,
Xiaowei

Daniel F.

Hey Xiaowei,

actually this is the format identifier I've added to mdfimport - are you sure the replacement of the m-files is ok?
Check your path of "mdfimport.m" using:
>> fileparts(which('mdfimport.m'))
and check if it's the new file.
You can also check from beginning of line 1845 if you can find "case 9 % INCA V7" then it has to work definitly.

If all this fails contact me again, maybe you can provide the measureing file.

Best regards,
Daniel

Xiaowei Ng

Hey Daniel, Thanks again for posting this and I'm glad there is a solution. But unfortunately I'm still having issues with MDFIMPORT.

I'm still getting:
[Warning: Conversion Formula type (conversionFormulaIdentifier=9)not supported.]
After I replace the matlab files. Any suggestions would be grateful!
Thanks!

Thank you very much.

Updates

1.0.0.0

Repack, since 7zip could not handle windows-zip archives.

1.0.0.0

Description update only.

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

mdfimport/