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

 Akzeptierte Antwort

David Hill
David Hill am 2 Mär. 2022

0 Stimmen

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

1 Kommentar

Hamdan Almusaibeli
Hamdan Almusaibeli am 2 Mär. 2022
Bearbeitet: Hamdan Almusaibeli am 2 Mär. 2022
Hi David,
Thank you so much for the prompt response. Appreciate your answer.
That makes sense.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by