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

1 view (last 30 days)
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

Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!