MATLAB: For loop in parfor

for loopParallel Computing Toolboxparfor

I want to use a for-loop inside parfor, is it possible? If not what is the alternative?
Thanks,

Best Answer

Yes, it's possible. For example,
parfor ii=1:10
for jj=1:10
x(ii,jj) = rand
end
end
Note that this example is so computationally trivial that it is much slower than a serial version.