Parfor error: parfor variable is indexed in different ways
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Bernoulli Lizard
il 27 Mar 2013
Commentato: Denis Menshykau
il 28 Nov 2013
I am trying to convert my code to run in parallel, but I get an error when I use the parfor : "in a parfor loop, variable is indexed in different ways". I can not understand, how is this being indexed in different ways? The order that each iteration is completed does not matter, and each iteration is completely independent.
parfor g = 1:ng
[A] = function(g)
B(g, :, 1) = mean( A(:,:) );
B(g, :, 2) = std( A(:,:) );
thanks end
0 Commenti
Risposta accettata
Edric Ellis
il 27 Mar 2013
Your variable 'B' has two different lists of subscripts - to run in PARFOR, you need to provide precisely the same list of subscripts. You can fix this by converting your expression to be a single indexed assignment. You need something like this
numColsInB = size(B,2);
...
parfor ...
newVals = [mean(A(:, :)), std(A(:, :))];
B(g, :, 1:2) = reshape(newVals, 1, numColsInB, 2);
end
1 Commento
Denis Menshykau
il 28 Nov 2013
Dear Edric,
I have a similar problem. Following your example I created the following simple test:
nPar=10;
data=zeros(nPar,2);
parfor n=1:nPar
v1=n^2;
v2=n^2-1;
newV=[v1, v2];
data(n,1:2)=reshape(newV,1,2);
end
however matlab generates an error: "Error using testParfor Error: The variable data in a parfor cannot be classified."
What is the problem?
Regards, Denis
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!