K-mean Clustering

5 次查看(过去 30 天)
MAT NIZAM UTI
MAT NIZAM UTI 2021-11-9
Hi Everyone, can someone help me on how to use the K-mean clustering or perhaps share with me the suitable coding use to cluster wind speed data. I hava wind speed data in the form of Latitude, Longitude, Wind Speed. I want to cluster the data into 3 groups.

采纳的回答

Image Analyst
Image Analyst 2021-11-12
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 个评论
Image Analyst
Image Analyst 2021-11-18
So can we just take the first 2314 values and ignore the extra lat?
MAT NIZAM UTI
MAT NIZAM UTI 2021-11-18
编辑:MAT NIZAM UTI 2021-11-18
Sure..well I dont really know how the matlab works, because after comparing the actual values and the after read values, both lons and speeds were different with the actual data.
https://drive.google.com/drive/folders/1tFOl0ZHQo4XzB-VGvi-LBLPg_lERG98u (this is my very actual data) Column C until LB is the wind speeds values.

请先登录,再进行评论。

更多回答(1 个)

H R
H R 2021-11-9
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 个评论
H R
H R 2021-11-12
Yes, every thing is possible (even using 1D data) , but you have to finally check what you are looking for from the clustering task and check if the outcome makes sense to you.
MAT NIZAM UTI
MAT NIZAM UTI 2021-11-14
编辑:Image Analyst 2021-11-14
Here is my coding, and I have an error on it
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in k_mean (line 7)
idx1=kmeans([X1 Y1],numClusters,'Replicates',5);
This is the code:
k = xlsread('WIND_26YEARS.csv');
X1=(1:6943);
Y1=randn(6943,1);
numClusters=3;
idx1=kmeans([X1 Y1],numClusters,'Replicates',5);
pointclust=repmat(idx1,1,numClusters)==repmat(1:numClusters,numel(idx1),1);
colors=hsv(numClusters);
for j=1:numClusters,
plot(X1(pointclust(:,j)),Y1(pointclust(:,j)),'Color',colors(j,:));
if j==1,
hold on;
end;
end,
hold off;

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by