How can I use the values in a vector to use/represent the indices of another vector or matrix?

Suppose, I have a vector vec_indices = [10; 14; 78; 2; 67; ...; ..;]. And I have another logical vector vec_log of size 67 x 1 (67 rows, 1 column).
Let's initialize vec_log as vec_log = zeros(67,1);
I want to use the values of vec_indices, i.e, extract values 10, 14, 72 and use them as INDICES of vec_log i.e. use vec_log(10), vec_log(14),.. and set vec_log(10) = 1, vec_log(14) = 1 etc.
How do I achieve this in Matlab?

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!