Code covered by the BSD License  

Highlights from
Estimating the number of clusters via System Evolution

from Estimating the number of clusters via System Evolution by Kaijun Wang
estimate number of clusters for far clusters, small-larger clusters, slightly overlapping clusters

[ft,fd]=plotindice(ind,N1,N2,km,newp,subp,pcolor)
function [ft,fd]=plotindice(ind,N1,N2,km,newp,subp,pcolor)

if pcolor 
    p1='r*';c1='r';p2='b^';c2='b'; p3='m+'; c3='m-';p4='kx'; c4='k-';
else
    p1='k*';c1='k';p2='k^';c2='k'; p3='k+'; c3='k-';p4='kx'; c4='k-'; 
end

if newp==1 
    figure('name','indices plotting','numbertitle','off','color','white');
end
if subp>0 
    subplot(2,2,subp); 
end

plot(1:N2,ind(1,1:N2),p1); hold on;
plot(1:N2,ind(2,1:N2),p2); hold on;

if length(km) > 1
   plot(km(1),ind(1,km(1)),'ko','MarkerSize',11);
   plot(km(2),ind(1,km(2)),'ks','MarkerSize',11);
else
   plot(km,ind(1,km),'ks','MarkerSize',11);
end

plot(1:N2,ind(1,1:N2),c1); hold on;
plot(1:N2,ind(2,1:N2),c2); hold on;

if size(ind,1)>2 
    plot(1:N2,ind(3,1:N2),p3); hold on;
    plot(1:N2,ind(4,1:N2),p4); hold on;
    plot(1:N2,ind(3,1:N2),c3); hold on;
    plot(1:N2,ind(4,1:N2),c4); hold on;
end

[fd,ts]=max(max(ind));
[ft,ts]=min(min(ind));
ts=(fd-ft)*0.1;
ft=ft-ts; fd=fd+ts;
ylim([ft fd]);
xlim2([N1 N2]);
xlim([N1-0.2 N2+0.2]);
xlabel('number of clusters(k)','FontSize',11,'FontWeight','demi');
ylabel('Energy','FontSize',11,'FontWeight','demi');
legend('partition energy','merge energy','optimal k',1);

Contact us at files@mathworks.com