Clusterig points in clusters, separated by a minimum distance

10 vues (au cours des 30 derniers jours)
Alexamder Schweizer
Alexamder Schweizer le 19 Avr 2019
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

Réponses (1)

Akshat
Akshat le 4 Sep 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!

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by