parfor can not assign twice to same variable with different index?

1 view (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 9 Feb 2016
In a parfor loop all of the output references must be the same.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!