Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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....

Antworten (0)


Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by