Wrong indexing in parfor loop
Mostrar comentarios más antiguos
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 comentarios
Joachim Schlosser
el 10 de Nov. de 2015
Can you please verify your results? I correctly get all matrices with ones.
Walter Roberson
el 10 de Nov. de 2015
Also which MATLAB version is being used on which operating system?
Andre Zeug
el 10 de Nov. de 2015
Editada: Andre Zeug
el 10 de Nov. de 2015
Adam Barber
el 10 de Nov. de 2015
I was able to reproduce this on R2014a, but not R2015b on my system.
Andre Zeug
el 10 de Nov. de 2015
Editada: Andre Zeug
el 10 de Nov. de 2015
Respuestas (1)
Andre Zeug
el 11 de Nov. de 2015
Editada: Andre Zeug
el 11 de Nov. de 2015
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!