Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

For loop question help

1 Ansicht (letzte 30 Tage)
Emma
Emma am 5 Mär. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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?

Antworten (1)

the cyclist
the cyclist am 5 Mär. 2020
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)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by