필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
frankovaT
frankovaT 2020년 6월 2일
답변: madhan ravi 2020년 6월 2일
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?

답변 (1개)

madhan ravi
madhan ravi 2020년 6월 2일
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
>>

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by