I need help arranging two vectors
2 次查看(过去 30 天)
显示 更早的评论
Suppose I have an area vector, composed of two vectors, length and width multiplied together. If I arrange the area from low to high how can I arrange my vector of length and width to match the entries used in the newly arranged area vector. Example: Area(1) = 200, Length(1) = 100, Width(1) = 2, after I sort vector Area, Area(1) moves to Area(3), how do I move Length(1) to Length(3) and also Width(1) to Width(3). Note, my array has 5000 entries.
0 个评论
回答(2 个)
David Young
2015-3-15
[AreaSorted, idx] = sort(Area);
LengthSorted = Length(idx);
WidthSorted = Width(idx);
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!