⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kdtree_demo.m

📁 kd树的实现
💻 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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -