How can I perform a K-means cluster analysis of the data inside a cell array?

3 ビュー (過去 30 日間)
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?
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 22 日
Post your code
Patrick
Patrick 2013 年 10 月 23 日
idx=kmeans(X,5);
where X is my cell array, and I want 5 clusters of that data

サインインしてコメントする。

採用された回答

Jonathan LeSage
Jonathan LeSage 2013 年 10 月 23 日
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!
  1 件のコメント
seyed morteza mousavi
seyed morteza mousavi 2017 年 11 月 9 日
dear,i want kmeans clustering, i use kdd cup99 data base that is a table and have 41 features and 42th feature is class type(attack, normal,...) and 158560rows, feature 2 and 3 and 4 and 42 is not numerical and they are categorical and have character for example tcp,http,sf,... i use table2cell for following your order and when i use cell2mat matlab say that error: contents of the input cell array must be on the same type, before that i use kmeans for basic table and matlab say that: cannot accept complex data , what shoud i dooooo please help me

サインインしてコメントする。

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by