MATLAB: Reading times from *.dat files into MATLAB

.dat fileloading time into matlab

Dear MATLAB forumers,
I am having difficulties in loading times from .dat files into MATLAB.
My .dat file has the following structures:
20090629 00:00:40 201,39993.0004739931,2009,180,0000,8.09,154.00
The first column contains the year-month-day and the second column contains the hour-minute-second. I would like to load both the columns into MATLAB as 6 separate cells: year, month, day, hour, minutes, and seconds (as shown below):
2009 06 29 00 00 40
Hopefully you can shed some light on this!
Regards,
Jack

Best Answer

S = '20090629 00:00:40 201,39993.0004739931,2009,180,0000,8.09,154.00';
dv = sscanf(S,'%4d%2d%2d %2d:%2d:%2d',[1,6])