Convert signals of a mf4 file to double variables
44 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Walter Roberson
2022-8-31
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 个评论
Walter Roberson
2022-9-28
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!