I got 3 square cluster from 12 (x,y) points. How can I find out which points it is taking for making the clusters?
1 view (last 30 days)
Show older comments
Hi, I have gotten 12 points from the images. Then I ran the cluster program for those points. My cluster program is below:
X = [112 161;154 166;107 214;149 218;179 277;163 284;188 300;172 307;268 314;241 323;273 340;246 349]
D= pdist(X)
P=squareform (D)
Z= linkage (D)
T = cluster(Z,'maxclust',3)
Q= sprintf('X(i,1),X(i,2)');
axis ([0 700 0 540])
figure
for i=1:12
if T(i)==1
axis ([0 700 0 540])
plot (X(i,1),X(i,2),'Marker','p','Color', ('green'),'MarkerSize',20);
Q= sprintf('X(i,1),X(i,2)');
hold on;
end
if T(i)==2
axis ([0 700 0 540])
plot (X(i,1),X(i,2),'Marker','p','Color', ('red'),'MarkerSize',20);
hold on;
end
if T(i)==3
axis ([0 700 0 540])
plot (X(i,1),X(i,2),'Marker','p','Color', ('blue'),'MarkerSize',20);
hold on;
end
end
disp(Q);
Here X is the 12 points. After doing this it is making perfect 3 squares for every T(i). I gave the instruction to show the every (X(i,1),X(i,2) as Q. By this I could find out the exact 4 points of each and every squares. But unfortunately it is not showing those 4 points of each squares it is taking from X.
Can anyone help me that how can I see the 4 points of the squares it is taking from the 12 points? And how can I named them as square 1, square 2 and square 3?
Thanks in advanced.
0 Comments
Accepted Answer
Tom Lane
on 16 Nov 2012
I may not follow your request. The variable T indicates which row of X belongs to each cluster. If you want to show that on the plot, you could replace your plot command with something like
text(X(i,1),X(i,2),num2str(i),'Color','g')
This would show the number instead of the marker.
2 Comments
Tom Lane
on 26 Nov 2012
I'm not an expert with images. I can only tell you that the numbering produced by the cluster function is arbitrary. All the points assigned to cluster 1 are in the same cluster, but there is no sense in which that cluster can be regarded as first.
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!