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

📄 nearest.m

📁 使用matlab进行实现的kmeans算法。数据集。
💻 M
字号:
function [zj,j,d] = nearest(z,xi);% NEAREST: return the vector zj in z that is nearest to xi% [zj,j,d] = nearest(z,xi)%	z  - d*J vectors that need to be compared to xi%	xi - the vector that wants to be matched up with zj%	zj - the nearest vector to xi in z%	j  - the index of zj in z%	d  - the minimum distance% Copyright (c) 1995 Frank Dellaert% All rights Reserved[r,J] = size(z);if size(xi) ~= r, error('NEAREST: z and x need to be of same dimensions!'); endzj = z(:,1); j = 1;if (J==1), return, endd = norm(zj-xi);for i=2:J,  zi = z(:,i);  distance = norm(zi-xi);  if (distance<d), zj=zi; j=i; d=distance; endend

⌨️ 快捷键说明

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