1

我想要这个数据的树状图:

tt =  1.0e+03 *

第 1 至 5 列

3.8334    3.9707    3.8887    2.1713    2.5616

第 6 至 7 列

2.3764    2.4533

我在matlab中使用代码:

tree = linkage(tt,'average');
figure()
dendrogram(tree)

但它给出了这个错误:

使用链接时出错(第 137 行)

第一个输入似乎不是距离矩阵,因为它的大小与 PDIST 函数的输出不兼容。数据矩阵输入必须多于一行。

有什么问题
,我希望输出是间隔。是树状图输出间隔吗?

4

1 回答 1

0

The input to linkage is arranged with rows as observations and columns as variables, but in your example tt is a 1x7 row vector, suggesting a single observation at each of 7 variables. Instead, transpose tt to a column vector if this data represents 7 observations of a single variable, and you can then plot the dendrogram:

% your original tt variable
tt = 1.0e+03 .* [3.8334 3.9707 3.8887 2.1713 2.5616 2.3764 2.4533];
% transpose from row vector to column vector
tt = tt';
% proceed as planned
tree = linkage(tt,'average');
figure()
dendrogram(tree)
于 2013-08-03T14:41:49.430 回答