Azzera filtri
Azzera filtri

sort 3 column matrix by two key words

2 visualizzazioni (ultimi 30 giorni)
how to do this in matlab? sort the matrix raws first by the first column, then by the second column?
input = [
1 2 11
1 2 11
1 2 12
1 2 11
1 2 11
1 2 12
1 3 17
1 3 15
1 4 18
1 4 18
1 3 15
1 3 16
2 3 17
2 3 15
1 3 16
1 3 17
1 3 15
1 3 15
1 3 15
1 3 16
1 2 12
1 2 11
1 2 11
1 2 11
1 4 18
1 4 18
1 4 18
2 4 17
2 4 17
1 4 17
1 4 17
1 4 17
]
output = [1 2 11
1 2 11
1 2 12
1 2 11
1 2 11
1 2 12
1 2 12
1 2 11
1 2 11
1 2 11
1 3 17
1 3 15
1 3 15
1 3 16
1 3 16
1 3 17
1 3 15
1 3 15
1 3 15
1 3 16
1 4 18
1 4 18
1 4 18
1 4 18
1 4 18
1 4 17
1 4 17
1 4 17
2 3 17
2 3 15
2 4 17
2 4 17
]

Risposta accettata

Walter Roberson
Walter Roberson il 5 Dic 2017
output sortrows(input, [1 2]);
  1 Commento
HONG CHENG
HONG CHENG il 5 Dic 2017
thanks a lot, this function is what I need.
I also have another question, maybe you are interested in it too
that problem in the link is based on this problem.

Accedi per commentare.

Più risposte (0)

Categorie

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

Community Treasure Hunt

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

Start Hunting!