필터 지우기
필터 지우기

Sorting array by datetimes does not work

조회 수: 12 (최근 30일)
Tycho Maas
Tycho Maas 2021년 1월 4일
댓글: Tycho Maas 2021년 1월 7일
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?

답변 (1개)

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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by