Page 87 - Algorithm Collections for Digital Signal Processing Applications using MATLAB
P. 87
2. Probability and Random Process 75
cov2(1,1)=sum(pw2x.*[(clustertot(1,:)-q(2,1)).*...
(clustertot(1,:)-q(2,1))])/sum(pw2x);
cov2(1,2)=sum(pw2x.*[(clustertot(1,:)-q(2,1)).*...
(clustertot(2,:)-q(2,2))])/sum(pw2x);
cov2(2,1)=sum(pw2x.*[(clustertot(2,:)-q(2,2)).*...
(clustertot(1,:)-q(2,1))])/sum(pw2x);
cov2(2,2)=sum(pw2x.*[(clustertot(2,:)-q(2,2)).*...
(clustertot(2,:)-q(2,2))])/sum(pw2x);
cov3(1,1)=sum(pw3x.*[(clustertot(1,:)-q(3,1)).*...
(clustertot(1,:)-q(3,1))])/sum(pw3x);
cov3(1,2)=sum(pw3x.*[(clustertot(1,:)-q(3,1)).*...
(clustertot(2,:)-q(3,2))])/sum(pw3x);
cov3(2,1)=sum(pw3x.*[(clustertot(2,:)-q(3,2)).*...
(clustertot(1,:)-q(3,1))])/sum(pw3x);
cov3(2,2)=sum(pw3x.*[(clustertot(2,:)-q(3,2)).*...
(clustertot(2,:)-q(3,2))])/sum(pw3x);
[p]=clusterno(clustertot,q);
w1=length(find(p==1))/length(p);
w2=length(find(p==2))/length(p);
w3=length(find(p==3))/length(p);
[m1,n1]=find(p==1);
collect1=clustertot(:,n1);
[m1,n1]=find(p==2);
collect2=clustertot(:,n1);
[m1,n1]=find(p==3);
collect3=clustertot(:,n1);
close all
plot(collect1(1,:),collect1(2,:),'r*')
hold on
plot(q(1,1),q(1,2),'co')
plot(collect2(1,:),collect2(2,:),'g*')
plot(q(2,1),q(2,2),'mo')
plot(collect3(1,:),collect3(2,:),'b*')
plot(q(3,1),q(3,2),'yo')
pause(0.3)
totcol1{j}=collect1;
totcol2{j}=collect2;
totcol3{j}=collect3;
qcol{j}=q;
end