Convert date and time to seconds
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ole
el 26 de Mayo de 2014
Respondida: the cyclist
el 26 de Mayo de 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 comentarios
Respuesta aceptada
the cyclist
el 26 de Mayo de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!