help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Optimization


From: Spam Family
Subject: Optimization
Date: Sun, 6 Oct 2013 11:53:53 -0500

I am trying to optimize our remove the for loop, and can't seem to find a better way...

I have to call the loop multiple times on large arrays.

% setup
num_points = 10000;
[X,Y] = meshgrid(1:100,1:100);
ropt = reshape([X,Y],10000,2);
optpoint = (unique(randi(5000,10,1)+2500))';
sampledist = randi(15,5000,2);
myarray = rand(10000,1);
ABCs = zeros(num_points,1);
sample=zeros(5000);

% code
tic
for curpoint = [optpoint] 
      
 sample = dsearchn(ropt(:,1:2),sampledist+ropt(curpoint,1:2));

 ABCs(curpoint) = sum(myarray(sample))/num_samples;

endfor
toc

Thank you for any help.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]