Sort row by descending error
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(3 个)
Walter Roberson
2017-7-5
The 'descend' option was not added until R2013b. Use
amaxfc = sortrows(amaxfc, -2);
0 个评论
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
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
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!