Borrar filtros
Borrar filtros

how to calculate time in matlab

9 visualizaciones (últimos 30 días)
zeezo
zeezo el 7 de Mayo de 2016
Comentada: the cyclist el 8 de Mayo de 2016
Hi, how can I write a time in matlab and add minutes to it. For example: how to write a time into the matrix a=[7:00 7:15 7:30] and how to add 60 seconds to 7:00 , 85sec to 7:15 and 136sec to 7:30
Thanks

Respuesta aceptada

Star Strider
Star Strider el 7 de Mayo de 2016
This will work in R2013b:
a=['7:00'; '7:15'; '7:30'];
% How to add 60 seconds to 7:00 , 85sec to 7:15 and 136sec to 7:30
add = [60; 85; 136];
sec_per_day = 24*60*60;
Result = datestr(datenum(a, 'HH:MM') + add/sec_per_day, 'HH:MM:SS')
Result =
07:01:00
07:16:25
07:32:16
  3 comentarios
Star Strider
Star Strider el 8 de Mayo de 2016
My pleasure.
zeezo
zeezo el 8 de Mayo de 2016
Editada: zeezo el 8 de Mayo de 2016
% Now I want to calculate the time different in a second between first result and the second result (example between 07:32:16 and 07:16:25)?

Iniciar sesión para comentar.

Más respuestas (1)

the cyclist
the cyclist el 7 de Mayo de 2016
If you have a relatively new version of MATLAB, you can use the datetime data type.
  2 comentarios
zeezo
zeezo el 7 de Mayo de 2016
Thanks I have R2013b. does it work in this?
the cyclist
the cyclist el 8 de Mayo de 2016
According to the documentation, that functionality was introduced in version R2014b.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by