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

📄 find_nnd.m

📁 计量工具箱
💻 M
字号:
% PURPOSE: An example of using find_nn()%          finds an index to the nearest neighbors %          demo for a small data set                   %---------------------------------------------------% USAGE: find_nnd%---------------------------------------------------clear all;% load Anselin (1988) Columbus neighborhood crime dataload anselin.dat; y = anselin(:,1); % neighborhood crime ratesxc = anselin(:,4);yc = anselin(:,5);% To find indexes to m neighbors% (where m is the # of nearest neighbors,)m = 3;index = find_nn(xc,yc,m);% pull out nearest neighbor values from yy1 = y(index(:,1),1); % pulls out nearest neighbor crime rates% plot crime rates in each neighborhood vs that in the nearest neighborplot(y,y1,'.g');xlabel('neighborhood crime rates');ylabel('nearest neighbor crime rates');fprintf(1,'in pause mode, hit any key to continue \n');pause;y2 = y(index(:,1),1)+y(index(:,2),1); % crime rates in nearest 2 neighborsy2 = y2/2; % an average of these% plot crime rates in each neighborhood vs the average in the nearest 2 neighborsplot(y,y2,'.r');xlabel('neighborhood crime rates');ylabel('average of 2 nearest neighbor crime rates');

⌨️ 快捷键说明

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