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

2018-05-16 Thread Heinz Nabielek
Histogram shows distribution of d and comparison with my model prediction. Heinz > On 16.05.2018, at 19:44, Heinz Nabielek wrote: > > Yes- factor 10. Great many thanks for all the help. > Heinz > >> On 16.05.2018, at 08:40, kjubo wrote: >> >>

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

2018-05-16 Thread Heinz Nabielek
Yes- factor 10. Great many thanks for all the help. Heinz > On 16.05.2018, at 08:40, kjubo wrote: > > Hello, > > d = zeros(n,1); > for ii=1:n; > //SqDist = (X-X(i))^2 + (Y-Y(i))^2 + (Z-Z(i))^2; >SqDist = (X-X(ii)).*(X-X(ii)) + (Y-Y(ii)).*(Y-Y(ii)) + >

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

2018-05-16 Thread Wozai
Hi, A very similar problem was discussed here in length. You'll find there numerous hints how to make your code faster. Cheers Wozai -- Sent from:

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

2018-05-16 Thread kjubo
Hello, d = zeros(n,1); for ii=1:n; //SqDist = (X-X(i))^2 + (Y-Y(i))^2 + (Z-Z(i))^2; SqDist = (X-X(ii)).*(X-X(ii)) + (Y-Y(ii)).*(Y-Y(ii)) + (Z-Z(ii)).*(Z-Z(ii)); SqDist(ii)= []; d(ii)= sqrt(min(SqDist)); end; some comments: * preallocate matrix * avoid unnecessary assign