The variable heuristic_map in a parfor cannot be classified.

2 vues (au cours des 30 derniers jours)
Jacek
Jacek le 17 Mar 2015
Commenté : Jacek le 18 Mar 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

Réponse acceptée

Edric Ellis
Edric Ellis le 18 Mar 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 commentaire
Jacek
Jacek le 18 Mar 2015
Thank you very much, I have read it but I must have misinterpret some details. It helped of course.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by