# The variable heuristic_map in a parfor cannot be classified.

1 view (last 30 days)
Jacek on 17 Mar 2015
Commented: Jacek on 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.

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