K means clustering error

1 次查看(过去 30 天)
Hello, I am trying to run K means clustering to group different types of clusters in my purchase order history. B represent a 16004 x 4 matrix and A represents a combination of 5 16004 x 1 matrixs. I am attempting to run the script below to view the different clusters.
A = table2cell([Age, Gender, City, Date, Product_ID])
B = cell2mat(A);
IDK = kmeans(B,4)
for k1 = 1:16004
text(B(:,1),B(:,2),B(:,3),B(:,4),B(:,5),num2str(IDK(k1))); hold on;
end
However an error continues to read
Error using text
Too many non-property/value arguments.
Please help! Thank you.

采纳的回答

Image Analyst
Image Analyst 2016-11-23
Maybe you want fprintf() instead????
fprintf('%f, %f, %f, %f, %f, %f\n', ...
B(:,1),B(:,2),B(:,3),B(:,4),B(:,5), IDK(k1));

更多回答(1 个)

Walter Roberson
Walter Roberson 2016-11-23
Look again at text(). The syntax for text is
text(x, y, strings, ...)
or
text(x, y, z, strings, ...)
so the either the 3rd or 4th argument must be a string or a cell array of strings. Your 4th argument is numeric.
It is not legal in MATLAB to place text at a 5 dimensional coordinate.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by