Hello,
I am trying to plot multiple H5 files on one plot so I want to loop thought a folder of H5 files. I am apble to read the data I want from the file I just want to be able to loop through them to make the process faster.

답변 (1개)

KSSV
KSSV 2020년 6월 9일

0 개 추천

H5files = dir('*.H5'); % give the extension if not it is H5
N = length(H5files) ;
for i = 1:N
thisFile = H5files(i).name ;
% do what you want
end

댓글 수: 2

Rachel Lackey
Rachel Lackey 2020년 6월 9일
편집: Rachel Lackey 2020년 6월 9일
Thanks for your help!
I have tried what you suggested but I it doesnt like the name of the file folder that I have placed all the H5 files I want to loop though in
This is the code I am using (including your suggestions)
H5files=dir('*H5');
N=length(42); %Number of files in the folder
for i=1:N
file=H5files(i).Premelt_01-05; %Name of the folder with H5 files I want to loop through
h_li_sigma=h5read('Premelt_01-05/gt2r/land_ice_segments/h_li_sigma');
lat1=h5read(Premelt_01-05'/gt2r/land_ice_segments/latitude');
long1=h5read('Premelt_01-05/gt2r/land_ice_segments/longitude');
x=lat1;
y=long1;
EM=h_li_sigma;
EM1=double(EM);
scatter(x,y,[],EM1,'s','filled')
colormap(jet)
end
KSSV
KSSV 2020년 6월 9일
Replace this line:
N=length(42); %Number of files in the folder
with
N=length(H5files); %Number of files in the folder

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2020년 6월 9일

댓글:

2020년 6월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by