0

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!!

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much @foxkingdom - This worked perfectly!! I had an idea of using string into number but didn't know how to execute. Appreciate the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.