how to solve the array index problem in kmeans clustering for three dimensional data?

2 ビュー (過去 30 日間)
AS
AS 2020 年 9 月 17 日
編集済み: AS 2020 年 9 月 17 日
I have used a with dimension 100 by 3 of 10 signals for kmeans clustering. So, I have used it as a three dimensional dataset of induvidual signal. I have used kmeans clustering but code is not working, showing the error index exceeds the number of array elements (1). Please provide me suggestion to solve out the problem.
niters=200;
Nouter=5;
nc=3; % clunster number
for kk=1:niters
for ii=1:100
for jj=1:10
old_c(:,:,jj)=c(:,:,jj);
d2(:,:,jj)=dist2(data(:,:,jj),c(:,:,jj));
[minval,indx]=min(d2(:,:,jj),[],2);
post1(:,:,jj)=id1(indx,jj);
num_points1(:,:,jj)= sum(post1(:,:,jj),1);
for k=1:Nouter
for n=1:nc
if num_points1(n) > 0
c(n,:,jj)=sum(data(find(post1(:,n,jj)),:,jj),1)./num_points1(:,jj);
end
end
e1(:,:,jj)=sum(minval);
errlog(kk)=e1(:,:,jj);
if kk>1
if max(max(abs(c(:,:,jj)-old_c(:,:,jj)))) < 0.0001 && abs(old_e(:,:,jj)-e1(:,:,jj)) < 0.0001
new_e(:,:,jj)=e1(:,:,jj);
return;
end
end
old_e(:,:,jj)=e1(:,:,jj);
end
new_e(:,:,jj)=e1(:,:,jj);
end
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by