Loading multiple h5 files in a for loop
5 views (last 30 days)
Show older comments
I am trying to load 20 h5 files into matlab using a for loop, but am running into problems. The h5 files have names with long strings of numbers, so here is my code so far:
for k = 130000:140000
Trial = sprintf('Vestibular\rawData\20190422-%d_Sway.h5', k);
if exist(Trial, 'file')
Trial_1 = functionread(Trial);
else
fprintf('File %s does not exist.\n', Trial);
end
end
From my understanding, this code should run through that "%d" in Trial for each value between 130,000 and 140,000, then apply the functionread (a separate code function; this works and isn't the problem) on the files with matching names according to the k values. However, I only get values for Trial (a 1x38 char vector). I am being thrown into the fire so to speak with MATLAB thus far, but some assistance or a hint would be extremely helpful since I will be processing lots of data soon using this kind of function.
Thanks,
B
0 Comments
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!