MATLAB Answers

1

Can we use parfor inside a for loop?

Asked by Sampath reddy on 14 Mar 2012
Can a parfor loop be used in side a for loop. I want to run a series of iterations with parfor inside the for loop. How to do this?

  0 Comments

Sign in to comment.

2 Answers

Answer by Sean de Wolski
on 14 Mar 2012

Sure!
matlabpool open 2
for ii = 1:3
parfor jj = 1:3
disp([ jj ii])
end
end
matlabpool close

  0 Comments

Sign in to comment.


Answer by Konrad Malkowski on 19 Mar 2012

If you have multiple nested for loop, then for best performance you really want the parfor to be the outermost loop in your program.

  0 Comments

Sign in to comment.