Reputation: 75
I'm working with Matlab and I need to sort the columns of a matrix by row. For example, if we have the next matrix
1 3 4
1 0 5
3 2 1
After ordering it by the last row
4 3 1
5 0 1
1 2 3
Is there a function that can do it?
Upvotes: 0
Views: 43
Reputation: 126
Use the following code.
A = [1, 3, 4;1, 0, 5;3, 2,1]
sorted = sortrows(A',3)'
For detailed information please type the following in your MATLAB command window.
help sortrows
Upvotes: 1