The variable heuristic_map in a parfor cannot be classified.

2 visualizaciones (últimos 30 días)
Jacek
Jacek el 17 de Mzo. de 2015
Comentada: Jacek el 18 de Mzo. de 2015
I went through tons and tons of documentation, online support, threads here and not only here, and everything implies that my code is perfectly ok, but there is still an error. My code:
parfor biases=1:numel(biass)
for ampl=1:numel(am)
[Amps,PHASES,~,~,~,~,~,~,~]=mod2((biases-1+b1)*biasdist,(ampl-1+am1)*amdist,N,w,action2);
[f_demod,~]=liczenie_P(refindex,sig,Amps,PHASES,k,biases,Omega,action2);
x=f_demod(center-limit:center+limit);
x=resample(x,up,ratio);
dif=abs(numel(x)-len);
x=x(round(dif/2)+shift1:end+shift2-round(dif/2));
x=x/max(x);
ccc=corrcoef(data,x);
cccc=ccc(1,2);
heuristic_map(ampl,biases)=cccc;
end
end
The variable heuristic_map in a parfor cannot be classified.
Please help me

Respuesta aceptada

Edric Ellis
Edric Ellis el 18 de Mzo. de 2015
I think the fix here is simple - when using a nested for loop inside a parfor loop, the bounds of that loop must be known to be constant for the duration of the parfor loop (at least if you want to "slice" a variable inside). In this case, you simply need to calculate numel(am) outside the loop, like so:
n_am = numel(am);
parfor biases = 1:numel(biass)
for ampl = 1:n_am
heuristic_map(ampl, biases) = ...;
end
end
This limitation is described in the documentation - see the section entitled Limitations of Nested for-Loops.
  1 comentario
Jacek
Jacek el 18 de Mzo. de 2015
Thank you very much, I have read it but I must have misinterpret some details. It helped of course.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by