take the Data after Clustering

조회 수: 21 (최근 30일)
Huy Cao
Huy Cao 2021년 11월 28일
댓글: Huy Cao 2021년 11월 28일
Hi, can anyone show me how to take the Data out after we used Clustering. After i used Kmeans Clustering I don't how to take the Data from each Cluster. Thank youuuuu
clear all
close all
clc
rng(2)
[num,txt,raw] = xlsread('ClusteringData.xlsx')
figure;
X=cell2mat(raw);
plot(X(:,2),X(:,1),'.');
[idx,C]= kmeans(X,5);
figure
title 'Kmeans Clustering';
xlabel 'Wing speed';
ylabel 'Power';
gscatter(X(:,2),X(:,1),idx)
hold on
plot(C(:,2),C(:,1),'kx')
legend('Cluster 1','Cluster 2','Cluster 3','Cluster 4','Cluster 5','Cluster Centroid')

채택된 답변

Image Analyst
Image Analyst 2021년 11월 28일
For example to extract out only class #2 you can use masking
class2Rows = idx == 2;
class2Data = X(class2Rows, :);
  댓글 수: 1
Huy Cao
Huy Cao 2021년 11월 28일
OMG you're the bestttt. Thank youuuuu

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by