Why there is a difference between sortrows(A) and sortrows(A,1)?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
madhan ravi
el 2 de Jun. de 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
>>
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!