Convert signals of a mf4 file to double variables

36 views (last 30 days)
Hey guys,
for a project I need to import a MF4 File and for further analysis it needs to be converted to double. It would also be very helpful to predetermine certain variables that are mandatory so that the entire mass of signals doesnt to be processed.
time should also be available as a variable.
as far as of now i got this far:
messdaten=file;
m=mdf(messdaten);
lengthChannelNames = length(m.ChannelNames);
data = cell(1, lengthChannelNames);
for k = 1:lengthChannelNames
data{k} = read(m, k, m.ChannelNames{k});
end

Answers (2)

Cris LaPierre
Cris LaPierre on 31 Aug 2022

Walter Roberson
Walter Roberson on 31 Aug 2022
https://www.mathworks.com/help/vnt/ug/read.html#bvcxtko-1
OutputFormat vector
Have you considered just making a single call rather than a loop? It would return a cell of timetable objects. You could cellfun(@(C)C{:,:}, data, 'UniformOutput', 0) to get a cell array of numeric data
  9 Comments
Dennis
Dennis on 18 Sep 2022
Edited: Dennis on 28 Sep 2022
So I converted the cell array with timetable to a cell array with tables.
Following that I would like to go thru each of the given tables in the cell and search for the variable names that are needed and save them like above in a vector.
For instance d2s should be searched for or accessed and then saved in a vector.
I dont know how to automate it thru each of the tables that are saved in the Cell array named table Cell. Please help!
Walter Roberson
Walter Roberson on 28 Sep 2022
When in doubt about how to do something to multiple items.. write a loop. It might give you code that is not as compact as it could be, but it will not necessarily be any slower. For example each time that cellfun() is used, you have to call through an anonymous function, possibly one with captured variables; if you write the equivalent loop code with a plain call to the work function without going through an anonymous function, the result might be faster than cellfun.
Except in some unusual cases involving real-time systems, it is almost always better to get the functionality working and correct first, and only then stress out about making it more compact or faster. As long as you have a version that is working correctly, (A) you might find it is fast enough anyhow and not worth the effort of improving; and (B) you can use the correctly-working version to compare results against proposed optimizations to be sure that the results are the same. Getting all of the "edge conditions" right with straight-forward code is easier than trying to figure out all of the edge conditions with more compact or more vectorized versions of the code. Your primary duty in the great majority of cases is to get the correct answer first, not to get the fastest or smallest version first.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!