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

 Réponse acceptée

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

1 commentaire

Hamdan Almusaibeli
Hamdan Almusaibeli le 2 Mar 2022
Modifié(e) : Hamdan Almusaibeli le 2 Mar 2022
Hi David,
Thank you so much for the prompt response. Appreciate your answer.
That makes sense.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by