Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
frankovaT
frankovaT am 2 Jun. 2020
Beantwortet: madhan ravi am 2 Jun. 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?

Antworten (1)

madhan ravi
madhan ravi am 2 Jun. 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
>>

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by