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.
Thanks for a useful code.
Can one use this code to draw an insert inside a subplot? I tried doing so by commenting the line in the code that creates new figure but that didn't work.
Comment only
05 Apr 2013
figure inset
The function plotting figure inside figure (main and inset) from 2 existing figures.
Thanks for a useful code.
Can one use this code to draw an insert inside a subplot? I tried doing so by commenting the line in the code that creates new figure but that didn't work.
4
20 Jan 2013
figure inset
The function plotting figure inside figure (main and inset) from 2 existing figures.
Hi Moshe,
Thanks for this useful code. I'm having a bit of bother trying to do something. I plot figure(1); I wish to inset a magnified portion of figure(1) (i.e. figure(2)) into figure(1) itself. Is this possible with your code?
Comment only