Indexing a vector in a particular fashion
1 次查看(过去 30 天)
显示 更早的评论
I have a vector: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
I want to index this vector in the following order: [9, 10, 7, 8, 5, 6, 3, 4, 1, 2]
How to do that?
0 个评论
回答(1 个)
Star Strider
2021-11-21
Index it pretty much exactly as ot was written —
v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
idx = [9, 10, 7, 8, 5, 6, 3, 4, 1, 2];
out = v(idx)
.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!