Why there is a difference between sortrows(A) and sortrows(A,1)?

1 vue (au cours des 30 derniers jours)
frankovaT
frankovaT le 2 Juin 2020
Hello all
I was wondering why there is difference between A=sortrows(A) and B=sortrows(A,1), denote that A is n by n matrix?
According to matlab documentation sortrows(A), sort the rows of a matrix in ascending order based on the elements in the first column. So I guess it should result in the same output as sortrows(A,1) which according to matlab, sorts A based on the columns specified in the vector column.
But when I look at the 5 first varaibles in A and B, I see different indexes.
index a=[7 10 17 35 41]
index b=[306 741 859 311 740]
What s happening?

Réponses (1)

madhan ravi
madhan ravi le 2 Juin 2020
I get the same results?
>> Matrix
Matrix =
1 1 4 2
4 4 4 5
2 2 3 1
3 4 1 5
>> B = sortrows(A)
B =
1 1 4 2
2 2 3 1
3 4 1 5
4 4 4 5
>> C = sortrows(A,1)
C =
1 1 4 2
2 2 3 1
3 4 1 5
4 4 4 5
>>

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by