0

I just got Octave Forge the other day, and am trying to run my MATLAB code. There's a line in my code that's giving me this error

warning: the 'knnsearch' function belongs to the statistics package from 
Octave Forge but has not yet been implemented.

Please read <http://www.octave.org/missing.html> to learn how you can
contribute missing functionality.

I've gone to the website and the knnsearch is missing, and I would have absolutely no idea how to implement it. My MATLAB code is as follows

[IDX,D] = knnsearch(histaxis,histaxis,'K',k);

where histaxis is a 7787x2 list of the positions of events and I choose k anywhere between 2 and 10000. The value I'm really interested in here is the distance to the kth nearest neighbour, D(:,k), the other information this gives is superfluous.

Is there another way to get this information that is available through Octave?

Thanks for your help :)

user1153070
  • 139
  • 8
  • You can consult the duplicate post for a scratch-made implementation of `knnsearch`. It's written for MATLAB, but the way I wrote it is compatible for Octave too. Good luck! – rayryeng May 12 '17 at 02:59
  • Thanks, that looks helpful.. I'm a little worried about the speed of it though - knnsearch is nice and fast and gets through comparing two lists of 7787x2 very quickly.. I'm not sure how quickly a for loop (or I guess I'll need a nested for loop?) will do it. But I'll give it a go :) – user1153070 May 12 '17 at 03:28
  • There are three implementations of `knnsearch` in the post - ranging from a simple `for` loop to using `bsxfun / permute`. I show them all as a base of comparison and how you would implement by brute force. Use the `bsxfun / permute` solution towards the end of the post as it's most certainly the fastest. Good luck! – rayryeng May 12 '17 at 03:28

0 Answers0