I don't know the details (perhaps another answer can get technical), but parfor loops don't like assigning values to things like x(ii, jj) directly, so you have to use temporary variables that are accessed only in the parfor loop. Try something like this....
a = linspace(0,10);
x=NaN(2,length(a));
parfor ii=1:2
tmp_var=NaN(1,length(a));
for jj=1:length(a)
tmp_var(jj) = rand;
end
x(ii,:) = tmp_var;
end
Best Answer