K means clustering error

2 views (last 30 days)
George Leavitt
George Leavitt on 23 Nov 2016
Answered: Image Analyst on 23 Nov 2016
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.

Accepted Answer

Image Analyst
Image Analyst on 23 Nov 2016
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));

More Answers (1)

Walter Roberson
Walter Roberson on 23 Nov 2016
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.

Tags

Community Treasure Hunt

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

Start Hunting!