Wrong indexing in parfor loop
Afficher commentaires plus anciens
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 commentaires
Joachim Schlosser
le 10 Nov 2015
Can you please verify your results? I correctly get all matrices with ones.
Walter Roberson
le 10 Nov 2015
Also which MATLAB version is being used on which operating system?
Andre Zeug
le 10 Nov 2015
Modifié(e) : Andre Zeug
le 10 Nov 2015
Adam Barber
le 10 Nov 2015
I was able to reproduce this on R2014a, but not R2015b on my system.
Andre Zeug
le 10 Nov 2015
Modifié(e) : Andre Zeug
le 10 Nov 2015
Réponses (1)
Andre Zeug
le 11 Nov 2015
Modifié(e) : Andre Zeug
le 11 Nov 2015
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!