Hendrick Wijaya
Hendrick Wijaya

Reputation: 47

labeling the x-coordinate on the dendrogram in matlab

I am still a beginner in using matlab. I would like to label the x coordinate of the dendrogram but do not know how. I had a case where I have data that will be used and stored in an excel file. An example of the contents of the data.

535110084   3.78    4.00    4.00    4.00    4.00    4.00    4.00    3.55    3.28    4.00
535110083   2.36    2.63    3.03    2.89    2.48    4.00    2.35    0.99    2.66    4.00
535110071   3.34    3.81    3.72    4.00    4.00    4.00    3.06    1.90    4.00    3.60
535110061   3.86    4.00    4.00    4.00    4.00    4.00    4.00    3.41    4.00    4.00
535100037   2.00    1.72    0.80    1.22    0.97    1.11    2.83    3.97    1.21    0.97
535100067   1.67    1.01    0.94    2.11    1.12    2.55    2.00    2.12    2.10    1.01
535120020   2.87    3.12    3.25    4.00    4.00    4.00    3.88    2.43    3.83    4.00
535120002   4.00    4.00    3.60    4.00    4.00    4.00    4.00    4.00    4.00    4.00

These data will be processed in matlab. I have code like this.

data = xlsread('apasaja.xlsx');
z = linkage(data(:,2:11),'single','euclidean')
dendrogram(z)

and dendrogram like this:

dendrogram

But dendrogram at coordinates x, the label does not change. I want to change the label on the x-coordinate. For example in the image data to the x coordinates dendrogram supposed 4 is 535130061, 8 is 535120002 etc. How to do it. Thank you

Upvotes: 1

Views: 361

Answers (1)

EBH
EBH

Reputation: 10440

It's quite simple:

dendrogram(z,'Labels',num2str(data(:,1)))

and you get:

dendo

Upvotes: 0

Related Questions