parallel_function error, "V must be a 3-D array"

Hi all, I'm trying to parallelize some of my code, and I have no idea how to fix this error. Here's the code:
energy=zeros(length(epsilon_theta),length(epsilon_r));
Emag=zeros(length(epsilon_theta),length(epsilon_r),21);
parfor m=1:length(epsilon_theta)
energy1=zeros(length(epsilon_r));
Emag1=zeros(length(epsilon_r),21);
for n=1:length(epsilon_r)
[energyf, Emagf, Source_Emag]=DDA_ExpRf_fun([epsilon_theta(m) epsilon_r(n)]);
energy1(n)=energyf;
Emag1(n,:)=Emagf;
end
energy(m,:)=energy1;
Emag(m,:,:)=Emag1;
end
When I run it, parfor breaks and returns
??? Error using ==> parallel_function at 598 Error in ==> interp3>linear at 320 V must be a 3-D array.
Does anyone know what could be the problem? Thanks! I'm totally new to parallel computing. Any other general tips on optimizing would be great as well.

1 个评论

Do thinks work correctly with MATLABPOOL closed? Do they work correctly with a FOR loop instead of a PARFOR loop? I presume your code in DDA_ExpRf_fun is calling interp3 - perhaps you should add some error checking that your variables are the correct size when you get there.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

提问:

2012-3-9

Community Treasure Hunt

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

Start Hunting!

Translated by