Difference between datetime values in minutes

1 visualización (últimos 30 días)
Tycho Maas
Tycho Maas el 30 de Dic. de 2020
Comentada: Ameer Hamza el 30 de Dic. de 2020
Hi,
I need some help. I have an array with multiple columns and with in one of these columns dates+times as a datetime format, this array is linked as data_combined.mat. The array looks like this:
06-Dec-2020 00:04:00 '06-Dec-2020' 7 76.8566666666667
06-Dec-2020 00:20:00 '06-Dec-2020' 6.30000000000000 77.6833333333333
06-Dec-2020 00:40:00 '06-Dec-2020' 5.10000000000000 78.7166666666667
I need help calculating the difference between the datetimes in minutes and creating a column containing these values. For example, this is what the above array would then look like:
1 06-Dec-2020 00:04:00 '06-Dec-2020' 7 76.8566666666667
17 06-Dec-2020 00:20:00 '06-Dec-2020' 6.30000000000000 77.6833333333333
37 06-Dec-2020 00:40:00 '06-Dec-2020' 5.10000000000000 78.7166666666667
Can anybody help me writing some code to do this?

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 30 de Dic. de 2020
Try this
col = minutes([all_combined_short{:,1}].'-all_combined_short{1,1})+1;
all_combined_short = [num2cell(col), all_combined_short]
  2 comentarios
Tycho Maas
Tycho Maas el 30 de Dic. de 2020
That works, thanks!
Ameer Hamza
Ameer Hamza el 30 de Dic. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by