How to group scattered points that visually belong to lines?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hong-Cin Liou
am 8 Jul. 2019
Kommentiert: Adam Danz
am 9 Jul. 2019
Hi there,
I have a set of scattered points look like this:
The data are stored in a x-vector and a y-vector and the sequence is random.
By visual, it is apparent that there are five lines from left to right and a V-shaped group of points, but how can I group the points that fall on the lines into separate arrays by code?
Thanks.
3 Kommentare
Akira Agata
am 9 Jul. 2019
Or "Hierarchical Clustering" would work.
If possible, I (... and many experts here) would be happy if you could upload your data here.
Akzeptierte Antwort
Adam Danz
am 9 Jul. 2019
Bearbeitet: Adam Danz
am 9 Jul. 2019
The data you provided was helpful. This should get you started. Check out the documentation for clusterdata() so you can tweak this if you decide to continue with this route.
The 'idx' variable below indicates the group number for each (X,Y) pair.
load('scattered points.mat')
idx = clusterdata([X',Y'],6);
gscatter(X,Y,idx)
2 Kommentare
Adam Danz
am 9 Jul. 2019
Thanks, glad I could help. There are a few ways to estimate the number of clusters but this is a common problem without a one-size-fits-all solution.
Search for "the elbow method of clustering" for one common approach.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!