www.gusucode.com > stats 源码程序 matlab案例代码 > stats/GrowADefaultkdTreeExample.m
%% Grow a Default _K_ d-Tree %% % Load Fisher's iris data set. % Copyright 2015 The MathWorks, Inc. load fisheriris X = meas; [n,k] = size(X) %% % |X| has 150 observations and 4 predictors. %% % Grow a 4-dimensional _K_ d-tree using the entire data set as training data. Mdl = KDTreeSearcher(X) %% % |Mdl| is a |KDTreeSearcher| model object, and its properties appear in % the Command Window. It contains information about the grown 4-dimensional % _K_ d-tree, such as the distance metric. You can alter property values % using dot notation %% % To find the nearest neighbors in |X| to a batch of query data, pass |Mdl| % and the query data to |knnsearch| or |rangesearch|.