How to assign values to arrays inside the PARFOR loop in Parallel Computing Toolbox?
Afficher commentaires plus anciens
I tried to assign valued to a matrix at specified locations at each loop, but it did not work. It showed that the variable 'A' cannot be classified in parfor-loop. Maybe the problem came from the sliced variable 'b(:,i)'. But I do not know how to modify it.
A = rand(10, 10);
%b = (2:4);
b = zeros(3,4)
b(:,1) = [1 2 3];
b(:,2) = [2 3 4];
b(:,3) = [3 4 5];
b(:,4) = [4 5 6];
parfor i = 1:4
A(b(:,i), i) = ones(3, 1);
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!