Sort row by descending error

조회 수: 2 (최근 30일)
yue ishida
yue ishida 2017년 7월 5일
편집: Jan 2017년 11월 11일
Hi. I have a cell like this.
A=
'Q7' [ 0]
'Q12H' [-3]
'Q12G' [ 0]
I want to sort by descending direction.
But it says that amaxfc=sortrows(amaxfc,2,'descend');
it says that
Error using sortrows
Too many input arguments.

답변 (3개)

Walter Roberson
Walter Roberson 2017년 7월 5일
The 'descend' option was not added until R2013b. Use
amaxfc = sortrows(amaxfc, -2);

Star Strider
Star Strider 2017년 7월 5일
Try this:
A = {'Q7' [ 0]
'Q12H' [-3]
'Q12G' [ 0]};
amaxfc=sortrows(A,2,'descend')
amaxfc =
3×2 cell array
'Q7' [ 0]
'Q12G' [ 0]
'Q12H' [-3]
  댓글 수: 3
Vicki Lewis
Vicki Lewis 2017년 11월 10일
same here on 2016b I get this error
[a,b]=sortrows(data,2,'descend')
Error using sortrows
Too many input arguments.
Star Strider
Star Strider 2017년 11월 11일
I no longer have access to R2016b, so I can’t experiment with it.
Do you have a different variable or function called ‘sortrows’?
See what:
which sortrows -all
reveals.

댓글을 달려면 로그인하십시오.


Jan
Jan 2017년 11월 11일
편집: Jan 2017년 11월 11일
According to the documentation of sortrows in R2016b, I see only numerical arrays, CHAR matrices and tables as input, but not cell arrays. But the code works for cells also.
According to the help text and the source code, there are 2 inputs only in R2016b. Therefore the error message is expected and clear.
The 3rd input works only in R2016b, if you apply sortrows to a table object.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by