Filter löschen
Filter löschen

sort from largest to smallest

129 Ansichten (letzte 30 Tage)
Quynh tran
Quynh tran am 19 Mai 2017
Kommentiert: Steven Lord am 12 Aug. 2019
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

Akzeptierte Antwort

James Tursa
James Tursa am 19 Mai 2017
Bearbeitet: James Tursa am 19 Mai 2017
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 Kommentare
antlhem
antlhem am 7 Aug. 2019
Hi, wat's the oposite of flipud? I want to sort the whole rows in ascedent way
Steven Lord
Steven Lord am 12 Aug. 2019
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by