The variable heuristic_map in a parfor cannot be classified.

2 次查看(过去 30 天)
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

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by