Page 88 - Algorithm Collections for Digital Signal Processing Applications using MATLAB
P. 88
76 Chapter 2
___________________________________________________________
clustercol.m
function [res] =clustercol(pos,N)
x1=rand(1,N)/4-(0.25)/2;
y1=rand(1,N)/4-(0.25)/2;
res=[x1+pos(1);y1+pos(2)];
_______________________________________________________________________
clusterno.m
function [q]=clusterno(clustertot,q)
d1=(clustertot'-repmat(q(1,:),length(clustertot),1)).^2;
d1=sum(d1');
d2=(clustertot'-repmat(q(2,:),length(clustertot),1)).^2;
d2=sum(d2');
d3=(clustertot'-repmat(q(3,:),length(clustertot),1)).^2;
d3=sum(d3');
[p,q]=min([d1;d2;d3]);
________________________________________________________________________
2.4 Program Illustration