Hi everyone,
Sortrows function seems to return incorrect arranged array, here is very specfice example.
A = [110.359026830732,-23.6025085449219,2.30662154653535; ...
110.359026830732,-23.6025085449219,2.93833414713542; ...
110.359026830732,-23.6025085449219,2.30662154653535]
In array A, the first and last point is the same and should be returned in position 1 and 2. But point 3 will be returned in position 3. However, output is not correct as below:
B = sortrows(A,[1 2],{'ascend','ascend'})
>> B =
110.3590 -23.6025 2.3066
110.3590 -23.6025 2.9383
110.3590 -23.6025 2.3066
Checking if the rows 1 and 3 are same:
A(1,:) == A(3,:)
ans =
1×3 logical array
1 1 1
Is it because I am using the double array format? any help will be appreciated.
Thank you

 채택된 답변

David Hill
David Hill 2022년 3월 2일

0 개 추천

B=sortrows(A);%if you just sort based on columns [1 2] no sorting will happen since then are all equal

댓글 수: 1

Hamdan Almusaibeli
Hamdan Almusaibeli 2022년 3월 2일
편집: Hamdan Almusaibeli 2022년 3월 2일
Hi David,
Thank you so much for the prompt response. Appreciate your answer.
That makes sense.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by