フィルターのクリア

Why is it that this attempt to run a clustergram is not working?

3 ビュー (過去 30 日間)
evanma
evanma 2016 年 9 月 11 日
コメント済み: evanma 2016 年 9 月 11 日
I had looked at the distance functions documenting how to make custom distance functions as shown here: http://www.mathworks.com/help/stats/pdist.html So when I implemented it, it was as shown
XX = randn(214, 66);
weuc = @(XI,XJ,W)(sqrt(bsxfun(@minus,XI,XJ).^2 * W'));
Dwgt=pdist(XX',@(Xi,Xj) weuc(Xi,Xj,Wgts));
tree = linkage(XX','average');
figure()
leafOrder = optimalleaforder(tree,Dwgt);
dendrogram(tree,0,'colorthreshold',.3,'reorder',leafOrder) ;
clo=clustergram(XX(1:214,1:66),'linkage','complete','Standardize','none','RowPDist','euclidean','ColumnPDist',@(Xi,Xj) weuc(Xi,Xj),'Cluster', 'all','RowLabels',AA(1:214))
The weights are simply set to 1 so that for a 214 x 66 matrix the weights are a 66X 1 vector with all ones for their values.
So what happens is that the clustering works for the dendrogram but not for the clustergram. Ihad looked at the Matlab documentation to make sure I was using pdist correctly but it when I run it, Matlab just says
Error using clustergram>computeDendrogram (line 1273)
Encountered error while computing hierarchical clusters: Error evaluating distance function '@(Xi,Xj)weuc(Xi,Xj)'
Is there a reason, perhaps with the syntax I used, as to why this would be the case?
Thanks for any help you can provide.

採用された回答

Walter Roberson
Walter Roberson 2016 年 9 月 11 日
Your weuc requires three arguments, but the code is calling it with two arguments because you have
'ColumnPDist',@(Xi,Xj) weuc(Xi,Xj),
You need to create a W argument, even if it is just
'ColumnPDist',@(Xi,Xj) weuc(Xi, Xj, 1),
  1 件のコメント
evanma
evanma 2016 年 9 月 11 日
Thanks for pointing out where I was missing an argument. I had somehow not seen the missing argument, it worked when I put in @(Xi,Xj) weuc(Xi,Xj,Wgts) so that solved it (admittedly it is highly embarrassing to miss something like that as I have been running code for hours on end over the last several months but in any event thank you for helping me see what I missed).

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by