How to find elements of an array by using another array elements as indices
Afficher commentaires plus anciens
Hi everyone,
Let's say
A= [2 5 4 3 5 7 5 6 8 2 8 4 3 1 4];
B= [1 3 4 7];
I need to find elements of A by using elements of B as indices of elements of A. In other words, I need 1st, 3rd, 4th and 7th elements of A and information of indices is given in B. Is this possible without using for loop? If yes, how? I am glad if you can help.
2 commentaires
Stanislao Pinzón
le 17 Mai 2020
You can use
A(B)
madhan ravi
le 17 Mai 2020
Stanislao I suggest you to move it as an answer since it answers the question.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!