NN /
Matlab BindingsMatlab Bindings for the NN CodeThe fast approximate nearest-neighbor code can be accessed from Matlab through a MEX (Matlab EXecutable) file. Using a MEX file we are able to combine the flexibility and ease-of-use of the matlab code with the performance of the compiled nearest-neighbor routines. Using the NN Code in MatlabThe MEX file is called 'nearest-neighbors' and it must be invoked with the following arguments:
where:
Example: >> dataset = single(load('dataset.dat'))'; >> testset = single(load('testset.dat'))'; >> >> [index,params] = nearest_neighbors('build_index',dataset,90); >> params params = 23 3 1 32 1 >> results = nearest_neighbors('index_find_nn',index,testset,1,params); >> nearest_neighbors('free_index',index); Alternatively, the index building and nearest-neighbor searching can be done in a single step in the following manner: >> dataset = single(load('dataset.dat'))'; >> testset = single(load('testset.dat'))'; >> results = nearest_neighbors('find_nn',dataset,testset,1,90); |