Sort a Matrix based on a column
1 次查看(过去 30 天)
显示 更早的评论
I want to sort a matrix. Actually I want to sort the last column and all the rest columns based on the last. Has anyone idea about this???
0 个评论
采纳的回答
Walter Roberson
2011-12-9
[lastvals, idx] = sort(A(:,end));
sortedA = A(idx,:);
2 个评论
Azzi Abdelmalek
2014-2-19
[Kris zenitis commented]
I ve got a matrix 4000x9. When i tried your solution i got Index exceeds matrix dimensions.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!