Obtaining values from selected iterations in a for loop then applying to all iterations
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 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!