[Scilab-users] any suggestion to make my Scilab code faster would be welcome:

Heinz Nabielek heinznabielek at me.com
Wed May 16 00:20:16 CEST 2018


Friends and colleagues:

I have already a pretty efficient Scilab code, but any suggestion to make it faster would be welcome:

I have position measurements of 20,000 objects in 3d space stored in column vectors X, Y, Z and want to explore the distribution of nearest neighbour distances. This works well like below, but an acceleration would help me a lot.

Heinz

n=length(X);
d=[];
for i=1:n; 
x=X(i);y=Y(i);z=Z(i);
SqDist=(X-x)^2 + (Y-y)^2 + (Z-z)^2;
SqDist(i)=[];
d=[d; sqrt(min(SqDist))];
end;


.. and 'd' gives me the desired distribution in a column vector of n elements


More information about the users mailing list