I have the matrix as follows
a = 1 3 2 5 3 2 4 8 5 9
I want to sort the second column in the a matri
a
Try this:
sortrows(a,2)
This should sort according to the second column.
or use:
[val idx]=sort(a(:,2)); ans = [a(idx,1) val]