MATLAB: Matlabpool open local (inside a loop)

matlabpoolparallel

Hey! I am making this script where I need to have matlabpool open local inside a loop because I would be executing the same code on different amounts of workers. The problem is that when I start my loop at i=1, and then put matlabpool open local i, matlab does not want to take i as the number of workers I want, I only can take a number instead of a variable. Is there any way of having matlabpool open local inside a loop and changing the amount of workers each time? Thanks!

Best Answer

matlabpool('open','local',i)
but are you sure that you want to allocate 1 worker to the first iteration, 2 workers to the second iteration, and so on ?