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

Antworten (1)

Ichechi Weli
Ichechi Weli am 10 Feb. 2020

0 Stimmen

As of MATLAB 2019b, if you get that error you can use the mdfsort function to sort the file beforehand.

2 Kommentare

Rangaraj Durai
Rangaraj Durai am 11 Apr. 2020
Hello Ichechi Weli,
I face similar problem with mdf files. Is there any workaround available for 2016R ?
Thanks
Rangaraj
Ichechi Weli
Ichechi Weli am 13 Apr. 2020
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

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2018b

Gefragt:

am 1 Mär. 2019

Kommentiert:

am 13 Apr. 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by