Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: cluster analysis
Replies: 1   Last Post: Jan 15, 2013 12:02 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Tom Lane

Posts: 855
Registered: 12/7/04
Re: cluster analysis
Posted: Jan 15, 2013 12:02 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

>> Once you find the cluster centroids you can associate new data example to
>> the cluster centers by measuring again the distance (pdist again with one
>> entry for each centroid plus un additional entry for each new example).
>> Then the analog cluster is the cluster which centroid has the minimal
>> distance.

...
> I tried to do what you suggested but without success. Can you post a code
> example please?


Manuel, if you have centroids and new data, you can locate the nearest
centroid to each new point using the pdist2 function like so:

>> centroids = [1 1 1;2 2 2;3 3 3];
>> newdata = 4*rand(4,3)

newdata =
2.6274 3.8670 3.4303
0.9275 2.4399 2.4142
2.4878 1.5349 3.3914
0.3005 0.1223 2.0185
>> dists = pdist2(newdata,centroids)
dists =
4.0957 2.4341 1.0372
2.0195 1.2309 2.2253
2.8668 1.5460 1.6007
1.5156 2.5327 4.0660
>> [~,minloc] = min(dists,[],2)
minloc =
3
2
2
1

However, your original code seemed to me to produce cluster numbers rather
than centroids.

-- Tom





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.