Proper classification of variables in parfor loop
1 次查看(过去 30 天)
显示 更早的评论
Hi there I have a loop that I would like to run with parfor. A simplified version of the code is
parfor qx_index=1:Nsx*Nx
for qy_index=1:Nsx*Nx
chi(qx_index,qy_index,:)=function(other_variables,qx_index,qy_index)
end
end
When I run the code I get the following error:
Error: The variable chi in a parfor cannot be classified.
I cannot figure out why this doesn't work - help?
0 个评论
回答(1 个)
Sean de Wolski
2014-8-5
编辑:Sean de Wolski
2014-8-5
What you have above works fine for me (filling in a few of the blanks)...
chi = zeros(2,3);
parfor qx_index=1:2
for qy_index=1:3
chi(qx_index,qy_index,:)=afunction(qx_index,qy_index)
end
end
And
function z = afunction(y,x)
z = y*x;
3 个评论
Adam
2014-8-5
There are a number of rules surrounding the functions you can use in a parfor loop. For example you cannot use nested functions or non-transparent functions like eval. Maybe your function does not meet these criteria?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!