kmeans clustering of matrices/arrays
3 views (last 30 days)
Show older comments
I have a 1X52 cell. Each element of cell is a 33X35 matrix. Need to classify these matrices using kmeans. I tried kmeans(X,k). But it demands X to be a matrix and not a cell.
Is there any other way?
2 Comments
Wayne King
on 5 Jan 2014
Edited: Wayne King
on 5 Jan 2014
Are you trying to work with each matrix separately, or are you trying to cluster the large matrix -- (52*33,35)
assuming each row is an observation on 35 variables and the variables are the same for each matrix.
Answers (1)
Image Analyst
on 5 Jan 2014
So make it a 3D array, which I would have done in the first place. Why mess with cells when you don't have to?
Anyway, since you have cells, just extract X from the cell and call kmeans
for c = 1 : length(myCellArray)
X = myCellArray{c}; % Extract double array from cell.
out = kmeans(X,k);
end
2 Comments
Walter Roberson
on 6 Jan 2014
That can happen by chance with random initialization. It can, though, also happen if you have a number of duplicate points.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!