MATLAB: Parfor can not assign twice to same variable with different index

parfor

I have this loop that I wanted to try parfor on which is basically the same as
if true
% code
width = 100;
array = zeros(1, width);
parfor i = 1:10;
array(i) = i;
array(width-i) = width - i;
end
end
where the same array is assigned twice but with different indices. There are some more computation in my for loop before assigning the values, but Matlab complains about the assignments. So I suppose this is not possible right?
The way to do it would be to compute first in one (par)for loop and then assign the array in two separate parfor loops?

Best Answer

In a parfor loop all of the output references must be the same.