sorting vectors
显示 更早的评论
To anyone out there who can help!
This seems to be an easy enough problem however I cannot seem to figure it out..
I have two vectors x=[25,69,45,53] y=[160,201,199,450]
I want to have an output that will sort x from smallest to largest and then display its corresponding y values..if that doesn't make sense I am trying to get a result thatlooks like this y=[160,199,450,201]
回答(1 个)
Teja Muppirala
2011-5-3
Call sort with a second output argument.
x=[25,69,45,53];
y=[160,201,199,450];
[xsorted, I] = sort(x)
ysorted = y(I)
类别
在 帮助中心 和 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!