Info

此问题已关闭。 请重新打开它进行编辑或回答。

For loop question help

1 次查看(过去 30 天)
Emma
Emma 2020-3-5
关闭: MATLAB Answer Bot 2021-8-20
I have two vectors. A = [ 1 2 3 4 6] and x = [5 3 2 1]. For every value in x, I want to return the corresponding index value in A. For example, the first value of x is 5, so I want the loop to return A(5) =6. How could I do this?

回答(1 个)

the cyclist
the cyclist 2020-3-5
You don't need a loop.
output = A(x);
gives you all the values at once. (Then you can loop over that if you need to)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by