sort each row of a matrix in a descending order

3 visualizaciones (últimos 30 días)
alpedhuez
alpedhuez el 15 de Jul. de 2022
Editada: alpedhuez el 15 de Jul. de 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]

Respuesta aceptada

Stephen23
Stephen23 el 15 de Jul. de 2022
Editada: Stephen23 el 15 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by