I need to run a for-loop in batches of 1000. But if 'cc' doesn't reach 100 during the first run, I need to re-run more batches of 1000 until cc reaches 100.
I know that this can be done using a while-loop, however I need to use the parallel toolbox parfor (quite possibly GPU's as well), and as far as I know it doesn't support while-loops.
Essentially I need to change (reset) the for-loop index inside the if-loop. However, apparently MATLAB's for-loop is designed so that you cannot change its index, in this case, 'i', within the loop. Is there a way around this? There must be a smarter way to do this without using a while loop. Any suggestions?
for i=1:1000
if (abs(i) <= gamma)
% etc..
cc = cc + 1;
end
if cc < 100
i = 1;
end
end
cc >= 100first, and then do the rest in parallel afterwards?forloop in to aparforloop so it can be run across multiple workers?parforthats fine for now.