I have this piece of code which I want to run in parallel. One of the arguments passed to the function containing the parfor loop is a function handle which then is executed inside the parfor loop. Like this
[X] = randstep( X,params,roomfun )
...
parfor i=1:N
while ~ok
X(:,i) = A*X(:,i);
if roomfun(X(:,i))
ok = 1;
end
end
end
However, MATLAB complains about roomfun, saying it is indexed but not sliced. This is of course not the case since it is function which can be executed fine without the other loop iterations.
Is there any way I can tell matlab this is a function or maybe another way I can organize the loops in order to get this running in parallel?