Code covered by the BSD License  

Highlights from
Kdtree implementation in matlab

5.0

5.0 | 3 ratings Rate this file 42 Downloads (last 30 days) File Size: 59.39 KB File ID: #26649
image thumbnail

Kdtree implementation in matlab

by Pramod Vemulapalli

 

11 Feb 2010 (Updated 17 Feb 2010)

The code contains a kd tree implementation in Matlab

| Watch this File

File Information
Description

Most of the kdtree code for matlab has been implemented via mex files. I decided to come up with a purely matlab based implementation and so here it is .... The code is obviously expected to be slower than some of the c/c++ implementations that are out there but the fact that its implemented in matlab might make it useful in certain circumstances. Matlab doesnot have pointers and so i mimicked the pointer functionality by using a global cell array. I will appreciate any feedback on my submission ........

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
k-D tree, kd-tree for matlab, KD Tree Nearest Neighbor and Range Search

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
12 Feb 2010 Andrea Tagliasacchi

I haven't tried it but it's a very good idea, so people don't have to compile any source and still achieve some speedup.

I think you should provide comparison in terms of running time though. That will guide the visitors to make the correct choice...

12 Feb 2010 Andrea Tagliasacchi

I didn't mean to give a 5/5 as I haven't tried it...
The form froze and it got ranked automatically...

11 Apr 2010 Erik

Works great.
As you say the other implementations out there makes use of mex files. This being pure m files and with w ell commentated code makes it easy to modify for altered use. I added a stored functionvalue at every node. Works great so far!

Well done!

22 Jun 2010 Ilia Zveda

There is a bug in file kd_closestpointgood.m on lines 111 and 112
They are:
if (~isempty(tree_cell_2(node_number).left)) kd_closestpointgood(0,point,tree_cell_2(node_number).right);

Line 111 should instead check right not left:
if (~isempty(tree_cell_2(node_number).right))

22 Jun 2010 Ilia Zveda

The same error also occurs on line 80.

03 Oct 2010 kale Peng

the same in kd_closestpointfast.m line 66

although this program is good

04 Oct 2010 kale Peng

In addition, kd_nclosestpoints.m needs lots of change in order to use it. Even different type structure.

14 May 2011 gurleen Sohi

hi..actually i need matlab code for the design of IIR filter low pass filter i.e magnitude and group delay using genetic algorithm in matlab...reply me on my email address gurleensohi@yahoo.com

05 Nov 2011 fzec

I have some bugs while using the function kd_nclosestpoints. It throws errors about the number of elements that the members of the kdtree struct have. i.e.:

??? Error using ==> gt
Too many input arguments.

Error in ==> kd_nclosestpoints at 21
    if(n>tree.numpoints)

I am using R2008a.

This is the same for tree.type, etc..

Thanks.

Please login to add a comment or rating.
Updates
12 Feb 2010

Wanted to acknowledge some of the other submissions on the topic

12 Feb 2010

Fixed a bug in kd_knn.m , Also wanted to acknowledge the contribution of Steven Michael
 

17 Feb 2010

Fixed a bug in the tree generation code ... and made corresponding changes in the other files

Tag Activity for this File
Tag Applied By Date/Time
kdtree Pramod Vemulapalli 12 Feb 2010 10:16:50
k dimensional tree Pramod Vemulapalli 12 Feb 2010 10:16:50
data structures Pramod Vemulapalli 12 Feb 2010 10:16:50
k nearest neighbors Pramod Vemulapalli 12 Feb 2010 10:16:50

Contact us at files@mathworks.com