sort each row of a matrix in a descending order

3 visualizzazioni (ultimi 30 giorni)
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]

Risposta accettata

Stephen23
Stephen23 il 15 Lug 2022
Modificato: Stephen23 il 15 Lug 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

Più risposte (0)

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by