"Mina" wrote in message <firstname.lastname@example.org>...
> I was wondering if you found the solution to your problem for 3D data clustering. I have the same issue.
I have just been working with the same issue.
Im not sure if my solution will help but here goes...
I had a 3d matrix (PxQxR) in my case 50x50x50 logical.
I then created from this a 125000x4 which held the element location in x,y,z and then its value.
1 1 1 0
1 1 2 0
1 1 3 0
I created this with a nested for loop to go over my 50x50x50 array but im sure there is a much better way of doing so! I have only been using matlab for about 2 weeks.Youll have to bare with me.
using this new matrix passed to Matlabs built in kmeans function
[cidx, ctrs] = kmeans(new_matrix(:,1:3), num_centroids);
And then i plotted them using plot3
hold on ; plot3(new_matrix(cidx==2,1),new_matrix(cidx==2,2),new_matrix(cidx==2,3),'g.');
hold on ; plot3(new_matrix(cidx==3,1),new_matrix(cidx==3,2),new_matrix(cidx==3,3),'r.');
hold on ; plot3(new_matrix(cidx==4,1),new_matrix(cidx==4,2),new_matrix(cidx==4,3),'w.');
hold on ; plot3( ctrs(:,1),ctrs(:,2),ctrs(:,3),'kx');
Hope this helps