I'm trying to speed up my simulation by incorporating parfor, but I do not seem able to return vectors. what basically will happen is that I define a system of odes (lorenz equations) and every parfor iteration would than just have a different set of initial conditions and calculate a path of like 100 steps. I use convhull to get the volume of each new sphere and save those in a vector and I want to do some postprocessing on this matrix of vectors.
paths = 5;
o=10;
b=8/3;
r = 28;
dt=0.001;
radius = 10^-10;
volumedata = zeros(1020, 1020);
parfor i = 1:paths
volumedataa=[];
p=35*rand;
j=35*rand;
k=35*rand;
[x,y,z]=sphere(10);
xpar=radius.*x(:)+p;ypar=radius.*y(:)+j;zpar=radius.*z(:)+k;
volumeworkerdata = [];
for j = 1:100
xpar=xpar+(o.*(ypar-xpar)).*dt;
ypar=ypar+(r.*xpar-ypar-xpar.*zpar).*dt;
zpar=zpar+(xpar.*ypar-zpar.*b).*dt;
v=[xpar ypar zpar];
[tri, volume] = convhull(v);
volumeworkerdata = [volumeworkerdata volume];
end
volumedata(i,:) = volumeworkerdata;
end
I keep getting errors and was hopeing that one of you would know how to get this working or if there is a better way to do this in parallel