Wrong indexing in parfor loop
显示 更早的评论
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 个评论
Joachim Schlosser
2015-11-10
Can you please verify your results? I correctly get all matrices with ones.
Walter Roberson
2015-11-10
Also which MATLAB version is being used on which operating system?
Andre Zeug
2015-11-10
编辑:Andre Zeug
2015-11-10
Adam Barber
2015-11-10
I was able to reproduce this on R2014a, but not R2015b on my system.
Andre Zeug
2015-11-10
编辑:Andre Zeug
2015-11-10
回答(1 个)
Andre Zeug
2015-11-11
编辑:Andre Zeug
2015-11-11
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!