How to use a list of indices to extract elements without for loop?

19 ビュー (過去 30 日間)
giacomo baccolo
giacomo baccolo 2020 年 9 月 25 日
コメント済み: giacomo baccolo 2020 年 9 月 29 日
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 !

採用された回答

madhan ravi
madhan ravi 2020 年 9 月 28 日
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.
  1 件のコメント
giacomo baccolo
giacomo baccolo 2020 年 9 月 29 日
thank you, I thought so but I wanted to be sure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by