您描述的聚类方法是DBSCAN。请注意,该算法只会在提供的数据中找到一个集群,因为数据集中不太可能存在一个点,因此它与 所有 其他点的距离超过 10.
如果这确实是您想要的,您可以使用ِDBSCAN,如果您使用的是早于 2019a 的版本,则可以使用 the one posted in FE。
% Generating random points, almost similar to the data provided by OP
data = bsxfun(@times, rand(100, 2), [100 1]);
% Adding more random points
for i=1:5
mu = rand(1, 2)*100 -50;
A = rand(2)*5;
sigma = A*A'+eye(2)*(1+rand*2);%[1,1.5;1.5,3];
data = [data;mvnrnd(mu,sigma,20)];
end
% clustering using DBSCAN, with epsilon = 10, and min-points = 1 as
idx = DBSCAN(data, 10, 1);
% plotting clusters
numCluster = max(idx);
colors = lines(numCluster);
scatter(data(:, 1), data(:, 2), 30, colors(idx, :), 'filled')
title(['No. of Clusters: ' num2str(numCluster)])
axis equal
上图中的数字表示任意两个不同簇中最近的点对之间的距离。