Clusterig points in clusters, separated by a minimum distance

조회 수: 10 (최근 30일)
Alexamder Schweizer
Alexamder Schweizer 2019년 4월 19일
답변: Akshat 2024년 9월 4일
I have a set of 300 points, defined by x and y coordinates in separat vectors. I want to cluster the points in such a way, that every center of the cluster is at least a defined distance from the closest other one. The distance can not be less than the defined one.
Is there a way that I dont have to define the exact number of clusters?
Which function should I use?
Thanks in advance for the response

답변 (1개)

Akshat
Akshat 2024년 9월 4일
Hi Alexamder,
The functionality you are asking for, which involves clustering points with a threshold for a neighborhood search radius, is provided in MATLAB using "dbscan".
Here is the documentation for the same:
I have written a sample code with 300 points for you to see how the function works, here:
x = rand(300, 1) * 100;
y = rand(300, 1) * 100;
data = [x, y];
epsilon = 5; % Minimum distance between cluster centers
min_samples = 5; % Minimum number of points to form a cluster
idx = dbscan(data, epsilon, min_samples);
figure;
gscatter(data(:,1), data(:,2), idx);
xlabel('X');
ylabel('Y');
grid on;
Hope this helps with your problem statement!

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by