how to read different file name using for loops

9 次查看(过去 30 天)
I have GPM half hourly precipitation data sets with different file names, my script example and a file name is attached below, every folder has single day half hourly data sets,
Number of files per folder=48; attachments filelist=example of a file name; extraction= current program file;
I need to convert all half-hourly file into daily;

采纳的回答

KSSV
KSSV 2018-10-3
files = dir('*.HDF5') ;
N = length(files) ;
for i = 1:N
thisfile = files(i).name ;
% do what you want ;
end
  1 个评论
Stephen23
Stephen23 2018-10-3
shanka sharma'a "Answer" moved here and formatted properly:
@KSSV i am trying to read file by year,month,day-startime-endtime.minute using loop such as
clc,clear all
%file name=3B-HHR.MS.MRG.3IMERG.20140412-S000000-E002959.0000.V05B.HDF5
days=[31 28 31 30 31 30 31 31 30 31 30 31];
year=2013;
for i=1:3
year=year+1;
month=1;
for j=1:12
month=1+(j-1)
day=1;
for jj=1:days(j);
hour=1;
for k=1:24
if rem(k,2)==0
hour=0+(k-1)*10000;
else
hour=3000+(k-1)*10000;
end
minute=30*(k-1);
minute=minute+30
sec=hour+2959;
if month<10
filein=['C:\NEW_DATA_SETS\imerg\3B-HHR.MS.MRG.3IMERG.' num2str(year) ...
'' num2str(month) '' num2str(jj) '-S' num2str(hour) '-E' num2str(sec) ...
'.' num2str(minute) '.V05B.HDF5'];
else
filein=['C:\NEW_DATA_SETS\imerg\3B-HHR.MS.MRG.3IMERG.' num2str(year) ...
'' num2str(j) '' num2str(jj) '-S' num2str(hour) '-E' num2str(sec) ...
'.' num2str(minute) '.V05B.HDF5'];
end
end
end
end
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by