聚类算法matlab程序

聚类算法matlab程序

ID:37789180

大小:39.00 KB

页数:5页

时间:2019-05-31

聚类算法matlab程序_第1页
聚类算法matlab程序_第2页
聚类算法matlab程序_第3页
聚类算法matlab程序_第4页
聚类算法matlab程序_第5页
资源描述:

《聚类算法matlab程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、clearallclosealldisp('Theonlyinputneededisadistancematrixfile')disp('Theformatofthisfileshouldbe:')disp('Column1:idofelementi')disp('Column2:idofelementj')disp('Column3:dist(i,j)')mdist=input('example_distances');%nameofthedistancematrixfile(withsinglequotes)?disp('Readinginputdistancema

2、trix')xx=load(mdist);ND=max(xx(:,2));NL=max(xx(:,1));if(NL>ND)ND=NL;endN=size(xx,1);fori=1:NDforj=1:NDdist(i,j)=0;endendfori=1:Nii=xx(i,1);jj=xx(i,2);dist(ii,jj)=xx(i,3);dist(jj,ii)=xx(i,3);endpercent=2.0;fprintf('averagepercentageofneighbours(hardcoded):%5.6f',percent);position=round(N*

3、percent/100);sda=sort(xx(:,3));dc=sda(position);fprintf('ComputingRhowithgaussiankernelofradius:%12.6f',dc);fori=1:NDrho(i)=0.;end%%Gaussiankernel%fori=1:ND-1forj=i+1:NDrho(i)=rho(i)+exp(-(dist(i,j)/dc)*(dist(i,j)/dc));rho(j)=rho(j)+exp(-(dist(i,j)/dc)*(dist(i,j)/dc));endend%%"Cutoff"ker

4、nel%%fori=1:ND-1%forj=i+1:ND%if(dist(i,j)

5、lta(ordrho(ii))=dist(ordrho(ii),ordrho(jj));nneigh(ordrho(ii))=ordrho(jj);endendenddelta(ordrho(1))=max(delta(:));disp('Generatedfile:DECISIONGRAPH')disp('column1:Density')disp('column2:Delta')fid=fopen('DECISION_GRAPH','w');fori=1:NDfprintf(fid,'%6.2f%6.2f',rho(i),delta(i));enddisp('Sel

6、ectarectangleenclosingclustercenters')scrsz=get(0,'ScreenSize');figure('Position',[672scrsz(3)/4.scrsz(4)/1.3]);fori=1:NDind(i)=i;gamma(i)=rho(i)*delta(i);endsubplot(2,1,1)tt=plot(rho(:),delta(:),'o','MarkerSize',5,'MarkerFaceColor','k','MarkerEdgeColor','k');title('DecisionGraph','FontSiz

7、e',15.0)xlabel('rho')ylabel('delta')subplot(2,1,1)rect=getrect(1);rhomin=rect(1);deltamin=rect(4);NCLUST=0;fori=1:NDcl(i)=-1;endfori=1:NDif((rho(i)>rhomin)&&(delta(i)>deltamin))NCLUST=NCLUST+1;cl(i)=NCLUST;icl(NCLUST)=i;endendfprintf('NUMBEROFCLUSTERS:%i',

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。