k-means clustering algorithm

조회 수: 2 (최근 30일)
AS
AS 2020년 7월 8일
I have a data with dimension 1801 by 88, to be clustered into k regions. Intially, all the centres are assigned randomly. the 'i' th data , sig is assigned to the nearest data cluster, c based on minimum Euclidean distance, where i=1:1801 and j=1:k. After completeing the assigning process for all the data, the new position of centre is measured according to
I have written the accordingly, but is not run and I am unable to understand about new position of the centre, although I have written. But not clear to me. How to add number of iteration in this code.
please help me
load signal.dat;
sig=signal(:,1:88);
[maxrow,maxcol]=size(sig);
k=1;
for i=1:k
p(i,:)=randperm(size(sig,1));
end
for i=1:k
for j=1:88
c(i,j)=sig(p(i),j);%random initialization
end
end
temp=zeros(maxrow,1);
while 1
for i1=1:1801
for j=1:88
d(:,j)=sum(dist2(sig(:,j),c(1,j)));
end
[z,g]=max(d,[],1);
if g==temp
break;
else
temp=g;
end
for i=1:k
f=find(g==i);
if f
c(i,:)=mean(sig(find(g==i),:),1);
end
end
end
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Cluster Analysis and Anomaly Detection에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by