Matlab聚类函数​linkage的聚类​中心怎么导出。

조회 수: 2 (최근 30일)
loaeena
loaeena 2023년 5월 17일
답변: hanaaua 2023년 5월 17일
代码如下
clc,clear
a=xlsread('C:\Users\hky的电脑\Desktop\','');
b=zscore(a);
r=corr(b,'type','Spearman')
d=tril(1-r);
%d=nonzeros(d)';
d=pdist(b','correlation');
z=linkage(d,'average');
h=dendrogram(z);
set(h,'Color','k','LineWidth',1.3);
n=5;
T=cluster(z,'maxclust',n);
for i = 1:n
tm =find(T==i);
tm=reshape(tm,1,length(tm));
fprintf('第%d类有%s\n',i,int2str(tm));
end
inconsistent0=inconsistent(z)

채택된 답변

hanaaua
hanaaua 2023년 5월 17일
clc,clear
a=xlsread('C:\Users\hky的电脑\Desktop\','');
b=zscore(a);
r=corr(b,'type','Spearman')
d=tril(1-r);
%d=nonzeros(d)';
d=pdist(b','correlation');
z=linkage(d,'average');
h=dendrogram(z);
set(h,'Color','k','LineWidth',1.3);
n=5;
T=cluster(z,'maxclust',n);
for i = 1:n
    tm =find(T==i);
    tm=reshape(tm,1,length(tm));
   
    fprintf('第%d类有%s\n',i,int2str(tm));
   
    di=d(tm,:);
    disp('聚类中心为:');
    mean(di)
end
inconsistent0=inconsistent(z)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 模块库에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!