The variable heuristic_map in a parfor cannot be classified.

2 views (last 30 days)
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

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!