Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Question on a simple "parfor loop"

1 visualización (últimos 30 días)
harry wang
harry wang el 23 de Nov. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi There,
I have a simple parfor loop as belows
c=1;
a=0;
parfor i=-90:90
c=i+91;
a(c)=3;
end
I thought in this way, each iteration is independent and satisfy the rule of parallel computing, but i still get an error message " The variable a in a parfor cannot be classified". Any one could let me know the reason and how to fix the code?
Thanks.

Respuestas (1)

Walter Roberson
Walter Roberson el 24 de Nov. de 2015
parfor i=-90:90
a(i+91)=3;
end
The parfor index variable must appear directly in the indexing expression, not as a variable computed based upon the indexing expression. This is a limitation on parfor to allow it to do static analysis.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by