Martin Larsen on Fri, 24 Mar 2006 17:00:28 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: sorting columns of a matrix |
How do I sort columns in a matrix? When I use vecsort, I can only sort the column according to one row, but I want to sort them according to all rows, so that all equal columns will be together. For example, 0 2 1 2 1 2 1 2 1 3 1 2 should become 0 1 1 2 2 2 1 1 1 2 2 3
See users.pdf: vecsort
m=[0,2,1,2,1,2;1,2,1,3,1,2]
[0 2 1 2 1 2] [1 2 1 3 1 2]
vecsort(m,[1,2])
[0 1 1 2 2 2] [1 1 1 2 2 3] Regards Martin