. , , parfor ( , ). , matlab , . :
fileDep = {'Compute2BodyForce',...
'Compute3BodyForce',...
'ComputeOtherForce'};
num_procs = 3;
matlabpool('open','Mycluster',num_procs,'FileDependencies',fileDep);
parfor iter = 1:3
% iter is passed to the functions so the functions can return NaNs when we don't want computation done
body_2_dummy{iter} = Compute2BodyForce(data,iter); %assuming data is a variable here, maybe a struct that gets parsed inside the functions
body_3_dummy{iter} = Compute3BodyForce(data,iter);
other_dummy{iter} = ComputeOtherForce(data,iter);
end
% resolve and sum up here
total_force = body_2_dummy{1} + body_3_dummy{2} + other_dummy{3};
, body_2_dummy {1}, body_3_dummy {2} other_dummy {3} NaN. Matlab. - :
parfor iter = 1:3
if iter == 1
body_2_dummy = Compute2Body(data);
end
% more ifs for the other forces
end
, body_2_dummy . Matlab , , body_2_dummy .
, . .
, , , . Matlab?
-
:
- - :
spam = @(x) x + 2;
spam(2)
ans = 4
- . , , @spam.
Sbiotoolbox. , Matlab. , , . Matlab.
, , , Matlab, . Matlab, .
Matlab - , Matlab. , , , , . , , , Matlab.
"" Matlab. , , .
.