sort from largest to smallest

129 次查看(过去 30 天)
Dear all, I have this matrix:
A=[1 3
3 6
4 7
5 8
6 2
8 3
9 6]
Could you help me how to arrange the first colum from max to min

采纳的回答

James Tursa
James Tursa 2017-5-19
编辑:James Tursa 2017-5-19
sort(A(:,1),'descend')
If you want to sort the matrix A by rows based on the first column, then e.g.
flipud(sortrows(A))
Or variations of the above based on what you want for output.
  3 个评论
antlhem
antlhem 2019-8-7
Hi, wat's the oposite of flipud? I want to sort the whole rows in ascedent way
Steven Lord
Steven Lord 2019-8-12
flipud is the opposite of flipud, but that's not the solution you're looking for. Either calling sort with 'ascend' instead of 'descend' or omitting that option entirely (since 'ascend' is the default direction) are the solutions you're looking for.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by