Clusterig points in clusters, separated by a minimum distance
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Akshat
on 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!
0 Comments
See Also
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!