Reputation: 93
This may be a simple question, but a matlab noob here and I can't find something similar in searching.
I have a bunch of filenames like this that I'm looping through: goes12.2009.242.201515.BAND_01.nc
I want to assign the 8-11th character (ie 2009) as the year, the 13-15th (ie 242) as the day, the 17-18th (ie 20) as the hour, the 19-20th (ie 15) as the min and the 21-22 (ie 15) as the second.
I believe this can be done somewhat simply? Thanks so much in advance for any insight!!
Upvotes: 0
Views: 61
Reputation: 56
sure, it can be done u just need to transform the string (character) into number
filename=goes12.2009.242.201515.BAND_01.nc;
yr=str2double(filename(8:11));
doy=str2double(filename(13:15));
hr=str2double(filename(17:18));
min=str2double(filename(19:20));
sec=str2double(filename(21:22));
and good luck with nc data
Upvotes: 1