Sorting array by datetimes does not work

7 visualizaciones (últimos 30 días)
Tycho Maas
Tycho Maas el 4 de En. de 2021
Comentada: Tycho Maas el 7 de En. de 2021
Hi,
I need to sort my array, notSorted.mat, by datetimes as strings. The code I use for this is the following:
[~, idx] = sort(datenum(notSorted(:,2), 'dd-MM-yyyy HH:mm'), 1, 'ascend');
sorted = notSorted(idx,:);
However, this does not work. Some values are still not correctly sorted. Does anybody know what went wrong?

Respuestas (1)

Mischa Kim
Mischa Kim el 4 de En. de 2021
Convert to and sort the table:
T = sortrows(cell2table(HR_date_time_strings),2)
  5 comentarios
Mischa Kim
Mischa Kim el 5 de En. de 2021
The code runs fine with R2020b. What release are you working with?
Tycho Maas
Tycho Maas el 7 de En. de 2021
It works now, somehow my MATLAB decided that after restarting it worked again...
Thanks!

Iniciar sesión para comentar.

Categorías

Más información sobre Shifting and Sorting Matrices 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