combined sorting
13 次查看(过去 30 天)
显示 更早的评论
For ex;I have an array A=[1:4] and B=[12:19:2:20].If I sort B in descending order B=[20 19 12 2].I want the corresponding positions in A to be swapped as well...ie A=[4 2 1 3].How do I achieve that?
0 个评论
采纳的回答
Matt Tearle
2011-4-3
[sortB,idx] = sort(B,'descend');
sortA = A(idx);
Or put the vectors into a matrix and use sortrows.
2 个评论
更多回答(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!