?? kdtree_demo.m
字號:
%% Demo of the KDTREE and KDTREEIDX function.%%%% Guy Shechter%% guy at jhu dot edu%% June 2004%% Generate a set of 10000 reference datapoints in R^5ReferencePts = rand(10000,5); %%% Build the k-d Tree once from the reference datapoints.[tmp, tmp, TreeRoot] = kdtree( ReferencePts, []);for Iteration = 1:10 disp(sprintf('Iteration %3d: ',Iteration)); %% Generate a random test set of 100 points in R^5 TestPoints = rand(100, 5); %% Find the closest point in ReferencePts for each random TestPoint [ ClosestPts, DistA, TreeRoot ] = kdtree([], TestPoints, ... TreeRoot); %% Find the row index of the closest point in ReferencePts for %each random TestPoint [ ClosestPtIndex, DistB, TreeRoot ] = kdtreeidx([], TestPoints, ... TreeRoot); %% Are the two solutions equivalent? IndexedPts = ReferencePts(ClosestPtIndex,:); if sum(sum(abs([ IndexedPts - ClosestPts ]))) == 0 disp('KDTREE and KDTREEIDX found the same set of closest points'); end end%%% Free the k-D Tree from memory.kdtree([],[],TreeRoot);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -