how to optimize a loop
古いコメントを表示
Hello.
I would like to ask if someone can suggest me a way to replace a for loop with a new/other function.Cause while I was working I realize I was using too many for loops.
Thanks
2 件のコメント
Walter Roberson
2022 年 1 月 11 日
Sometimes you can vectorize. Sometimes the only alternative to a for loop is a hidden for loop such as arrayfun
KSSV
2022 年 1 月 11 日
And we cannot help you unless the code is shown here and what cycles you want to optimize.
回答 (1 件)
Nihal Reddy
2022 年 1 月 25 日
0 投票
Hey Amina,
From my understanding, you want a replacement or alternative for “for” loop. In some of the cases, you can vectorize, and in the other cases, you can use a function that does the role of “for” loop for your specific requirement.
Refer to the following MATLAB Documentation page on how vectorization can be used in place of “for” loop.
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!