层次聚类之后如何得到新的中心点图。
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
果搏东方在线注册【微8785092】
le 17 Mai 2023
Réponse apportée : 果博厅注册网址【微8785092】
le 17 Mai 2023
各位大神,怎么做能将图中上面两个类各自只显示中心点。也就是红色的累两个点合成为一个点
clear,clc,close all
%导入数据
data = [1 0;2 0;3 5;4 8;5 15;6 0;7 0];
plot(data(:,1),data(:,2),'linestyle','none','marker','x')
%
close all
dis=pdist(data,'euclidean'); %用pdist函数计算变量之间的距离
SF =squareform(dis);
datalink = linkage(dis,'average'); %用 linkage函数定义变量之间的连接
%
% 绘制树状图
dendrogram(datalink);
%
T = cluster(datalink,'maxclust',3); %用cluster函数创建聚类
figure;
%绘制经过聚类的原始数据
gscatter(data(:,1),data(:,2),T)

0 commentaires
Réponse acceptée
果博厅注册网址【微8785092】
le 17 Mai 2023
可能需要做一些对应计算
更多的可参考
[attach]332027[/attach]
clc; clear all; close all
%导入数据
data = [1 0;2 0;3 5;4 8;5 15;6 0;7 0];
figure;
plot(data(:,1),data(:,2),'linestyle','none','marker','x')
dis=pdist(data,'euclidean'); %用pdist函数计算变量之间的距离
SF =squareform(dis);
datalink = linkage(dis,'average'); %用 linkage函数定义变量之间的连接
figure;
% 绘制树状图
dendrogram(datalink);
T = cluster(datalink,'maxclust',3); %用cluster函数创建聚类
figure;
%绘制经过聚类的原始数据
gscatter(data(:,1),data(:,2),T)
xm = get(gca, 'XLim');
ym = get(gca, 'YLim');
T2 = [];
for i = 1 : length(T)
if isempty(find(T2==T(i)))
T2(end+1) = T(i);
end
end
data2 = [];
for i = 1 : length(T2)
id = find(T==T2(i));
m = mean(data(id,:), 1);
data2(end+1, :) = m;
end
figure;
gscatter(data2(:,1),data2(:,2),T2)
set(gca, 'XLim', xm, 'YLim', ym);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!