Obtaining values from selected iterations in a for loop then applying to all iterations

1 回表示 (過去 30 日間)
Lina Koronfel
Lina Koronfel 2020 年 8 月 6 日
I'm using a for loop that runs 100 iterations.
I want to obtain a mean value of a certain parameter which appears only midway through the loop from say iteration number 2, 5, and 17, have it in the workspace, then apply this value to all iterations (kind of in retrospect) and carry on with the execution of the code.
What is the neatest and most efficient way to obtain a value that is reliant on specific, unordered iterations but necessary for all iterations in a for loop?
I though about copying the for loop for the selected iterations to obtain the required mean, then running the same thing again on all iterations in a following step, thus using two for loops, but that doesn't feel so efficient....

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by