Sort rows of a matrix

9 visualizaciones (últimos 30 días)
Gabriele Ansaldo
Gabriele Ansaldo el 14 de Mayo de 2020
Respondida: Fangjun Jiang el 14 de Mayo de 2020
Hello,
I would like to sort the rows of a matrix depending on the values of each row. So i sould sort the rows based on the first entry of the row, and then i would sort what i have based on the second row and so on. Here is an example, consider the following matrix
A =
1 2 3
1 2 4
3 1 2
1 1 1
The output should be the following
A =
1 1 1
1 2 3
1 2 4
3 1 2

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 14 de Mayo de 2020
sortrows()

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by