parfor can not assign twice to same variable with different index?
2 views (last 30 days)
Show older comments
Geir Paulsen
on 9 Feb 2016
Answered: Walter Roberson
on 9 Feb 2016
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?
0 Comments
Accepted Answer
Walter Roberson
on 9 Feb 2016
In a parfor loop all of the output references must be the same.
0 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!