Error clustering to k mean

1 view (last 30 days)
Lev Mihailov
Lev Mihailov on 8 Aug 2019
Commented: Lev Mihailov on 8 Aug 2019
A= [X1;X2];
[IDX,C,sumd,D] = kmeans(A,2,'display','iter'); %%% Error using kmeans (line 269)
%X must have more rows than the number of clusters.
%Error in Untitled (line 2)
[IDX,C,sumd,D] = kmeans(A,4,'display','iter');
figure(1)
subplot(2,1,1)
plot(A(:,1),A(:,2),'.')
subplot(2,1,2)
plot(A(IDX==1,1),A(IDX==1,2),'r.','MarkerSize',12);
hold on
plot(A(IDX==2,1),A(IDX==2,2),'b.','MarkerSize',12);
hold on
plot(A(IDX==3,1),A(IDX==3,2),'g.','MarkerSize',12);
hold on
plot(C(1,1),C(1,2),'x','color','k','LineWidth',6)
hold on
plot(C(2,1),C(2,2),'x','color','k','LineWidth',6)
hold on
plot(C(2,1),C(2,2),'x','color','k','LineWidth',6)
Hello! I have two signals and I want to cluster them k average, when setting 2 clusters everything is fine, but when I want to put 3 or more errors get out, help me fix it ps my signal is a pure signal X1 and a signal with noise X2
  1 Comment
Lev Mihailov
Lev Mihailov on 8 Aug 2019
idx = kmeans(X1,2);
% Plot results
hold on
plot(X(idx==1,1), X(idx==1,2), 'r.')
plot(X(idx==2,1), X(idx==2,2), 'g.')
plot(X(idx==3,1), X(idx==3,2), 'b.')
X must have more rows than the number of clusters.
Error in Untitled (line 2)
idx = kmeans(E1,2);
tried in this way to make all the mistake ps I have a 2x1000 matrix

Sign in to comment.

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!