Saturday, March 26, 2011

Matlab: Sort Arrays (e.g. sort by a given column)

I can also choose to sort all of A by a particular column. First sort that column, and then use those indices to sort the entire array.
[~, index2] = sort(A(:,2));
Asort2 = A(index2,:)

There is a very nice entry here:
http://blogs.mathworks.com/loren/2010/02/04/constrained-sorting-of-array/

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.