1

I would like to sort a Matrix in matlab taking into account multiple columns conditions. I have this Matrix that contains for each row 5 different parameters.

Matrix=[9   106 2   2   2
10  404 1   14  1
3   176 2   1   3
10  278 2   2   2
7   108 1   11  3
2   313 2   2   3
4   153 2   17  3
6   338 2   17  1
10  354 2   15  1
10  382 2   3   2
3   242 1   14  3
10  69  1   11  3
10  137 1   20  2
6   460 1   13  4
9   101 2   17  3
3   418 1   10  4]

Now, I would like to sort the matrix by first and second column in descendant order, in a few words, I'm looking for a method that generates a sort of compromise among two or more columns into the same matrix.

Thanks in advance

user3043636
  • 559
  • 6
  • 23
  • I'm sorry, but is different, since using sortrows there is not a compromise, sometimes the combinations of sortrows(Matrix,[1,2]) produces unwanted results. – user3043636 Jan 18 '16 at 11:54
  • Doesn't `sortrows(Matrix, [-1 -2])` do what you want? – Jørgen Jan 18 '16 at 12:59

0 Answers0