MDF (mf4) unsorted
显示 更早的评论
Hi all
I am trying to load a MDF (mf4) file into matlab using Vehicle Network Toolbox.
I execute the following to get file information:
m = mdf('C:\log_1.mf4');
m
m.ChannelGroup(1)
m.ChannelNames{1}
The result is:
m =
MDF with properties:
File Details
Name: 'log_1.mf4'
Path: 'C:\log_1.mf4'
Author: ''
Department: ''
Project: ''
Subject: ''
Comment: ''
Version: '4.11'
DataSize: 193468
InitialTimestamp: ''
File Contents
Attachment: [0×0 struct]
ChannelNames: {2×1 cell}
ChannelGroup: [1×2 struct]
ans =
struct with fields:
AcquisitionName: 'CAN'
Comment: ''
NumSamples: 3587
DataSize: 78914
Sorted: 0
Channel: [1×8 struct]
ans =
8×1 cell array
{'ID' }
{'IDE' }
{'DLC' }
{'DataLength' }
{'DataBytes' }
{'Dir' }
{'CAN_DataFrame'}
{'Timestamp' }
Then I run the following to read the log entris in the file:
read(m, 1, m.ChannelNames{1}, 1, 10)
The result is:
Error using mdfReadTest (line 12)
Functionality is not implemented for the MDF file.
It seems that Matlab is not able to load unsorted MDF files (Sorted: 0). It works if I use a third-party tool to first sort the file.
Can you confirm that it is not possible to load unsorted files in Matlab? And if so, any plans to add this functionality?
Thanks
Br
Christian
回答(1 个)
Ichechi Weli
2020-2-10
0 个投票
As of MATLAB 2019b, if you get that error you can use the mdfsort function to sort the file beforehand.
2 个评论
Rangaraj Durai
2020-4-11
Hello Ichechi Weli,
I face similar problem with mdf files. Is there any workaround available for 2016R ?
Thanks
Rangaraj
Ichechi Weli
2020-4-13
I'm not sure, I'd have to look into and find a workaound. But below is the built-in mdfsort.m function from R2019b, maybe you can play with it and come up with something that works.
function sortedMDFPath = mdfSort(srcFile, destFile)
% mdfSort Create a sorted copy of an unsorted MDF file.
% SORTEDMDFPATH = mdfSORT(SRCFILE, DESTFILE) takes an unsorted MDF file
% SRCFILE, and creates a sorted copy of that file as DESTFILE. The path
% to the sorted file is returned as SORTEDMDFPATH.
%
% Example:
% sortedPath = mdfSort('UnsortedMDFFile.mf4', 'SortedMDFFile.mf4');
% Copyright 2019, The MathWorks, Inc.
% Check the argument count.
narginchk(2, 2);
% Convert strings to character vectors.
srcFile = convertStringsToChars(srcFile);
destFile = convertStringsToChars(destFile);
% Call the MDF info function.
try
% Construct and run an input parser to check the inputs.
p = inputParser;
p.addRequired('srcFile', @(x)validateattributes(x, {'char'}, {'nonempty', 'row'}, 'MDFSORT', 'SRCFILE'));
p.addRequired('destFile', @(x)validateattributes(x, {'char'}, {'nonempty', 'row'}, 'MDFSORT', 'DESTFILE'));
p.parse(srcFile, destFile);
sortedMDFPath = asam.mdf.FileInterface.Sort(srcFile, destFile);
catch ME
% Simplify error reporting and call stack.
throwAsCaller(ME);
end
end
Good luck
类别
在 帮助中心 和 File Exchange 中查找有关 MDF Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!