Convert date and time to seconds
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ole
am 26 Mai 2014
Beantwortet: the cyclist
am 26 Mai 2014
Hi
I've measured a process as a function of time, and when I open the logging file (.txt) in MATLAB the date and time is saved in a char array. The measured variables are stored in an ordinary array. I have two columns (2 and 3) in the character array which contains date (dd.mm.yy) and time (HH:MM:SS). In total I have approximately 9000 rows of data. I would like to convert the date and time to seconds elapsed from first measured value. The first date and time registered would consequently be converted to approximately 0 seconds, the next would be 0seconds + x and so on.
date_string = strcat(textdata(2:end,2), {' '},textdata(2:end,3));
dateandtime = datenum(date_string, 'dd.mm.yyyy HH:MM:SS');
And then I'm stuck. I've been looking at etime, but it essentially only calculates the difference between two date vectors?
Thanks
0 Kommentare
Akzeptierte Antwort
the cyclist
am 26 Mai 2014
If I understand correctly, your variable dateandtime is going to be a vector of about 9000 date-times. The rest is simple:
dateandtime = (dateandtime-dateandtime(1)) * (24 * 60 * 60);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!