importdata not reading time stamp from excel sheet accurately
Ältere Kommentare anzeigen
I have been using importdata to read an excel sheet with time stamps. The time stamp on excel sheet is 1/1/2015 12:20:18 AM. When importdata is used, this time stamp gets converted to [42005.014097222]. I tried using datestr([42005.014097222],31) command and this is being converted to '0115-01-02 00:20:18'; but it has to be 2015-01-01 00:20:18'. How can this be fixed? Thank you!
Here is the program:
[filename, pathname] = uigetfile({'*.*'},'Choose the input file');
delimiterIn = ',';
headerlinesIn = 0;
A = importdata([pathname filename],delimiterIn,headerlinesIn); %this is a long array of time stamps, just citing one in the example above.
start_time=A(:,1); %start_time(1)=[42005.014097222]; but the 1st element in the excel sheet is 1/1/2015 12:20:18 AM
stop_time=A(:,2);
[y1,m1,d1,h1,m1,s1]=datevec(datestr(start_time,31)); %the result here gives me y1=115 and d1=2; but the right result should be y1=2015 and d1=1.
[y2,m2,d2,h2,m2,s2]=datevec(datestr(stop_time,31));
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Dates and Time finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!