sort each row of a matrix in a descending order

1 vue (au cours des 30 derniers jours)
alpedhuez
alpedhuez le 15 Juil 2022
Modifié(e) : alpedhuez le 15 Juil 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]

Réponse acceptée

Stephen23
Stephen23 le 15 Juil 2022
Modifié(e) : Stephen23 le 15 Juil 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

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by