For one dimensional data I am searching, the range search gives some results which are outside the specified range by a tiny bit. e.g. 4-5 orders of magnitude relative to the search window size.

example for reproducing this : (takes a few minutes to complete run)

rng('default')
for i=1:1000
x=rand(100000,1);
tree=kdtree(x);
r=[0.3331 1/3];
idx=kdtree_range(tree,r);
found=x(idx);
if any(found<r(1))
disp(i)
disp(found(found<r(1))-r(1))
end
if any(found>r(2))
disp(i)
disp(found(found>r(2))-r(2))
end
end

I just managed to compile mex files for this submission on windows 64.
It wasn't that easy, and I wasted a few good hours on that, but it works now.
I also admit I know almost nothing about compiling and so forth so there might be better ways to do it, but anyway these were my steps:

1. Installed MS Visual Studio 2010 (warning: it's not free, but luckily my helpdesk had a licensed copy)

2. Opened Matlab, typed
>> mex -setup
and went through the setup process.

3. opened the options file:
C:\Users\apaster\AppData\Roaming\MathWorks\MATLAB\R2011b\mexopts.bat
(find the right location by typing

and added the folder P:\Documents\MATLAB\kdtree\src that contained the source files of kdtree to the options file (lines 25-26):

set PATH=P:\Documents\MATLAB\kdtree\src;%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\bin;%VCINSTALLDIR%\VCPackages;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\Common7\Tools;%LINKERDIR%\bin\x64;%LINKERDIR%\bin;%MATLAB_BIN%;%PATH%

set INCLUDE=P:\Documents\MATLAB\kdtree\src;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\ATLMFC\INCLUDE;%LINKERDIR%\include;%INCLUDE%

seems like if we don't do that, the compiler won't be able to find the kdtree.h file

4. from Matlab, typed:
>> cd 'P:\Documents\MATLAB\kdtree\src'
>> mex kdtree.cpp kdtree_create.cpp
>> mex kdtree_range.cpp kdtree.cpp
>> mex kdtree_closestpoint.cpp kdtree.cpp

5. That's it ! Now just copied the .mexw64 files to \kdtree\@kdtree folder.

mpgwrite
The MPEG converter takes a MATLAB movie matrix and writes the movie to disk as an MPEG file.
Author: David Foti

To Dan Massie (03 Nov 2011) : the problem you noticed is due to the limitations of getframe command ( see http://www.mathworks.com/help/techdoc/ref/getframe.html ), and has nothing to do with mpgwrite.

While this short piece of code does create an inset for simple plots, it will break for slightly more sophisticated plots, e.g., plots with legends. Besides, the position of the inset is hard-coded.

Dear all,
First thanks to the Author for a nice submition I am using often to work with lidar point clouds.
But now I wish to use kdtree_range with multiple boxes & single call (making a loop takes for ages!). This is, I define the "range" as 3D array. An example what I did:
>> r = rand(5,2);
>> tree = kdtree(r);
>> boxm
boxm(:,:,1) =
0 0
0.5000 0.5000
1.0000 1.0000
boxm(:,:,2) =
0.5000 0.5000
1.0000 1.0000
1.5000 1.5000
>> kdtree_range(tree,boxm)
Multple range input must have size (N,ndim,2)
But the boxm HAS the size (N - number of boxes, ndim - which is two, 2)!?!
Any suggestios how to make it work?
Many thanks in advance!
Maja

Comment only

20 May 2013

figure inset
The function plotting figure inside figure (main and inset) from 2 existing figures.

Comment only