Clusterig points in clusters, separated by a minimum distance

4 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Akshat
Akshat il 4 Set 2024
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!

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by