Loading multiple h5 files in a for loop

2 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by