How to use a list of indices to extract elements without for loop?
14 views (last 30 days)
Show older comments
giacomo baccolo
on 25 Sep 2020
Commented: giacomo baccolo
on 29 Sep 2020
Hi guys,
I have to extract some elements from some structures and each structure is in cell.
Here is the for loop I'm using right now:
for i = 1:3
ext(i,:) = Models{toextract(i,1), toextract(i,2)}.scores(:,toextract(i,3));
end
toextract is a matrix where i have the indices that i need
can I avoid the for loop somehow?
Thank you !
0 Comments
Accepted Answer
madhan ravi
on 28 Sep 2020
No, you cannot. The alternaternative is to use arrayfun() and co, but it just has an implicit loop. So I would say a loop is much better in this case.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!