How to store values of iterations during a for loop?
2 views (last 30 days)
I have the following problem, I have three for loops, and I need to store the number of iterations that correspond to the second for loop, to show its total during the execution of the main loop. For example:
for i = 1:npop % first loop / npop = 600
for it = 1:iters % Main loop / iters = 100
for l = 1:nc % third loop / obj function evaluation / nc = 600
In the first loop npop = 600, in the second iters = 100 and in the third nc = 600. If anyone has experience what I am doing is a genetic algorithm in which I want to show the number of objective function evaluations.
Thanks in advance.
Madhav Thakker on 18 May 2021
Have a look at for loop documentation in MATLAB to know how it works.
Open this example in MATLAB command window to run and display values in each iteration.
Hope this helps.