Error in calculated dendrogram (compared with R)

2 views (last 30 days)
I am trying to make a dendrogram in Matlab based on a dissimilarity matrix X. I converted it into a format that linkage would accept by using Y=squareform(X). I get the following vector:
Y = [0 0 0 0 1.4476 0 0 0 0 0 0 0 0 0 1.7525 0 0 0 0 0 1.9634 11.3676 0 0 0 2.1579 14.4957 0 0 0 0 0 0 0 0 0];
I then tried to plot a dendrogram using complete linkage:
dendrogram(linkage(Y,'complete'))
and get the following result:
wrong_dendrogram.jpg
However, when I use the dissimilarity matrix X in R (also with the complete linkage method) I get a completely different dendrogram:
real_dendrogram.jpg
The dendrogram made with R makes a lot more sense with the input data than the matlab one.
Any idea why they are so different? And is there a way to reproduce it in matlab? I am trying to make an automized script that should create the dendrogram in the end, so having to switch programs every time would not be ideal.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!