2013-05-27 64 views
4

我已經存儲在文件stations.dat以下一組數據:相關的標籤的樹狀圖的情節 - MATLAB

 Station A 305.2 321.1 420.9 383.5 311.7 197.1 160.2 113.9 60.5 60.5 64.8 154.3 
     Station B 281.1 304.0 353.1 231.9 84.6 20.9 11.7 11.9 31.1 75.8 133.0 235.3 
     Station C 312.3 342.2 366.2 335.2 200.1 74.4 45.9 27.5 24.0 53.6 87.7 177.0 
     Station D 402.2 524.5 554.9 529.5 347.5 176.8 120.2 35.0 12.6 13.3 14.0 61.6 
     Station E 261.3 262.7 282.3 232.6 103.8 33.2 16.7 33.2 111.0 149.0 184.8 227.0 

通過使用下面的命令,

Z = linkage (stations.data,'ward','euc'); 
figure (1), dendrogram(Z,0,'orientation', 'right') 

我得到如下圖所示: enter image description here

所以,簇1的分量是4,3,1(站D,C和A,分別),簇2是5,2(站E和B)。

我希望把情節站的名稱,但如果我使用命令:

set (gca,'YTickLabel', stations.textdata); 

下圖我得到的是以下幾點: enter image description here

我怎麼能數據到各自的關聯樹狀圖中的名稱和陰謀。 我有144個電臺數據。我只用了5個插圖。

回答

8

嘗試以下操作:

ind = str2num(get(gca,'YTickLabel')); 
set(gca, 'YTickLabel',stations.textdata(ind)) 

一個簡單的方法是在dendrogram直接調用指定數據點的標籤:

dendrogram(Z,0, 'Orientation','right', 'Labels',stations.textdata) 

dendrogram

+0

是。它運作良好。正是我需要的!謝謝! –

+1

第二個選項也適用! –