Wrong indexing in parfor loop
1 view (last 30 days)
Show older comments
I tried to use parfor to change parts of a variable but receive unexpected result
d = ones(10,10);
d = repmat(d,[1 1 1 10]);
d(:,:,2,:) = .5*d(:,:,1,:);
parfor n=1:10;
d(:,:,2,n) = 2*d(:,:,2,n);
end
I expected to receive something like
d(:,:,2,:) = d(:,:,1,:);
Instead I get
d(:,:,1,:) = 2;
d(:,:,2,:) = .5;
What went wrong? Using for instead of parfor works fine.
Thanks
5 Comments
Answers (1)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!