regarding specific files from folder
3 ビュー (過去 30 日間)
古いコメントを表示
I have some data sets its for daily observations and I would like to read data for one month every time ( 30 files) and after that it should go to next month. can anybody tell me how to fix this problem?
0 件のコメント
採用された回答
Arturo Moncada-Torres
2011 年 8 月 19 日
Does this solution work for you? I have not tested it, let me know if it works.
files = dir('*.h5'); % Find the files with extension .h5 in the current directory.
monthsStr = {'01';'02';'03';'04';'05';'06';'07';'08';'09';'10';'11';'12'};
for ii = 1:numel(files) % In theory, you have 365 files.
for year = 2009:2010
for jj 1:numel(monthsStr)
nameFound = strfind(files(ii).name, ['GSAT' num2str(year) monthsStr{jj}]); % The mistake was here =P .
if nameFound
fid = fopen(files(ii).name);
% Do whatever you need with the files here.
fclose(fid);
end
end
end
end
2 件のコメント
Arturo Moncada-Torres
2011 年 8 月 19 日
My mistake, you must use "{" and "}" instead of "(" and ")". I edited the answer, take a look at it ;).
その他の回答 (1 件)
Wouter Donders
2011 年 8 月 19 日
Surely the filenames contain some coded tags with which you could identify which files go with which month?
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!