MATLAB: How to group scattered points that visually belong to lines

clusteringMATLAB

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.

Best Answer

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)