Saturday, May 14, 2011

Date and Time in File Name matlab

Printing Months name as string for data analysis.
This also checks the existence of the file with the extension ".ext"; say dec_09.ext.


months={'jan','feb','mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'};
for iyear=5: 9

year_st = num2str(iyear,'%2.2i');

for i=1:length(months)
fn=[months{i} '_' year_st '.ext'];
if exist(fn, 'file')

disp(fn)
else
continue
end
end
end

No comments: