On a quick thought, it would be something like this:
files = dir('*.h5');
month = '01';
for ii = 1:numel(files)
nameFound = strfind(files(ii).name, ['GSAT2009' month]);
if nameFound
fid = fopen(files(ii).name);
fclose(fid);
end
end
EDIT
If you want to read year information separately, you can use the following, which is very similar:
files = dir('*.h5');
month = '01';
year = '2009';
NOTE: If month or year are not strings and are numeric (double), you can use the function num2str.
for ii = 1:numel(files)
nameFound = strfind(files(ii).name, ['GSAT' year month]);
if nameFound
fid = fopen(files(ii).name);
fclose(fid);
end
end
Try it and let me know if it works.
Best Answer