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

1 visualización (últimos 30 días)
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....

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by