密度峰值聚类实验代码修正

由Alex Rodriguez和Alessandro Laio发表的《Clustering by fast search and find of density peaks》提出基于密度峰值聚类的算法,作者还给出了实验代码及案例数据,链接在这http://people.sissa.it/~laio/Research/Res_clustering.php,真的是十分良心呐~

于是开开心心代开matlab做实验,运行过程中报错,代码只显示原数据分布图,但不显示聚类结果:

字段赋值赋给非结构体数组对象。

出错 getrect (line 80)
GETRECT_FIG.Visible = 'on'; % make sure Live Editor figures are shown

出错 cluster_dp (line 103)
rect = getrect(1);

查阅网上资料感觉错误出在getrect函数。matlab官方文档中介绍 http://ww2.mathworks.cn/help/images/ref/getrect.html#d120e68722 给出了三种用法

rect = getrect
rect = getrect(fig)
rect = getrect(ax)
但是第三种在这里明显有问题,所以尝试第二种,修改102~103行代码如下:
fig=subplot(2,1,1)
rect = getrect(fig);
执行成功!接下来就该细细琢磨作者代码详细思路啦!
原文地址:https://www.cnblogs.com/kjkj/p/9728513.html