# K-mean Clustering

6 views (last 30 days)

Show older comments

MAT NIZAM UTI
on 9 Nov 2021

Edited: MAT NIZAM UTI
on 18 Nov 2021

##### 0 Comments

### Accepted Answer

Image Analyst
on 12 Nov 2021

If you have all the lat and lon values, then just put each into kmeans separately:

numColumns = 26; % Or however many columns you know there to be.

[xIndexes, xCentroids] = kmeans(lon, numColumns);

numRows = 50; % Or however many rows you know there to be.

[yIndexes, yCentroids] = kmeans(lat, numRows);

The values of the columns (x or longitude values) will be in xCentroids.

The values of the rows (y or lat values) will be in yCentroids.

##### 16 Comments

### More Answers (1)

H R
on 9 Nov 2021

If your data is in a matrix format X, then you can use the following:

[idx,C] = kmeans(X,3,'Distance','cityblock','Replicates',5);

##### 6 Comments

H R
on 12 Nov 2021

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!