sort each row of a matrix in a descending order

1 Ansicht (letzte 30 Tage)
alpedhuez
alpedhuez am 15 Jul. 2022
Bearbeitet: alpedhuez am 15 Jul. 2022
Suppose I have a matrix
[1 2 3
4 5 6
7 8 9]
I want to sort each row in a descending order so that it will be
[3 2 1
6 5 4
9 8 7]

Akzeptierte Antwort

Stephen23
Stephen23 am 15 Jul. 2022
Bearbeitet: Stephen23 am 15 Jul. 2022
A = [1 2 3; 4 5 6; 7 8 9]
A = 3×3
1 2 3 4 5 6 7 8 9
B = sort(A,2,'descend')
B = 3×3
3 2 1 6 5 4 9 8 7

Weitere Antworten (0)

Kategorien

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

Tags

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by