How can I perform a K-means cluster analysis of the data inside a cell array?
8 views (last 30 days)
Patrick on 21 Oct 2013
I have a cell array - 10368 cells with two values each. I would like to perform a K-means cluster analysis of this data, but every time I try, I get the following error messages:
Undefined function 'isnan' for input arguments of type 'cell'.
Error in statremovenan (line 29) wasnan = wasnan | any(isnan(y),2);
Error in kmeans (line 125) [~,wasnan,X] = statremovenan(X);
How can I solve this problem?
Jonathan LeSage on 23 Oct 2013
The documentation of the kmeans function that you are trying to use requires a data matrix as an input. The cell array cannot be used, and hence your error.
Since your data seems to be a 10368x2 cell array, you could try out the cell2mat function to first convert your data into a 10368x2 data matrix. From there, the kmeans function should work as expected!