sort a vecrtor
1 次查看(过去 30 天)
显示 更早的评论
I have a vector: a = [1 5 7 2 6 8 9 0 2] and b=[5 8 1 0 3 6 9 8 2] (both have the same size) I want to sort vector 'a' and accordingly vector 'b'.
a = [1 5 7 2 6 8 9 0 2] ;
b = [5 8 1 0 3 6 9 8 2] ;
[a1,ind]=sort(a) for i=1:length(a1)
b1(1,i)=b(1,ind(1,i));
end
It works. But I am wondering if there is a more professional way to get ride of this "for i=1:length(a1)" loop?
Thanks in advance.
0 个评论
采纳的回答
更多回答(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!