MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by huda nawaf on 28 Aug 2012

hi, I found the following code of matlab in this link http://www.ideal.ece.utexas.edu/~gjun/ee379k/html/clustering/hac/page2.html

load c.txt;

P=pdist(c,'euclidean');

Z=linkage(P,'single');

T=cluster(Z,'MaxClust',2);

plot_clusters(c,T);

I tried it with my data , it is working except the last function , it is what I looked for , this function plot each cluster with different color

how can find it? please, i badly need it in my work.

thanks

*No products are associated with this question.*

Answer by Oleg Komarov on 28 Aug 2012

Answer by huda nawaf on 28 Aug 2012

Edited by huda nawaf on 28 Aug 2012

Many thanks,

I got it and run it. But what if I ran the above code on my data but my data is not 2D , my data is n*n similarity matrix, and I ran the above function on my data

P=pdist(c,'euclidean');

Z=linkage(P,'single');

T=cluster(Z,'MaxClust',2);

and got T the label for each observations (n). Now , i want to use plot_clusters with this case . if plot_clusters is not working with this case, are there alternative way to see the clusters graphically.

thanks

Show 7 older comments

Oleg Komarov on 30 Aug 2012

As commented in your other post, with the similiarity matrix alone, all you can do is a dendrogram.

huda nawaf on 30 Aug 2012

Walter,

just need each cluster with differnt color and contain the number of objects inside it.

I sent image in that post. thanks

## 7 Comments

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/46882#comment_96439

Please, format your code: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/46882#comment_96458

@huda: I posted a link because there's a much easier facility to format the code.

After 130 and more question you still don't take the effort to watch (you don't even have to read) the .gif or to read some simple guidelines.

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/46882#comment_96475

I second Oleg's impression. Please, huda, show some respect and care about the conventions in the forum. I you do not care about making the questions as easy to understand as possible, the forum will loose the interest in your questions also.

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/46882#comment_96482

But my question is very clear, this is why Oleg reply to me . I'm agree with you just about format my code at first, later I formatted it.

nevertheless, I present my apology

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/46882#comment_96484

@huda: I had a teacher of biology in high school who used to say "I cannot spread apologies on my bread (in the morning when having breakfast)".

In brief, this is not the first time I post the link on how to format the question or the other link on how to ask a question properly. Also, it is common sense to provide the necessary information if you expect a reasonable answer. Thus, saying "I am sorry" and still keeping to post the same way is equivalent to fool us around. Obviously, that's my point of view.

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/46882#comment_96501

huda, you have not formatted the code in this post.

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/46882#comment_96562

@huda: Thanks for your apology. Apologies are not useful here, but improving your style to ask question is. Most of all this would be an advantage for me, the forum and last but not least for yourself.