sorting data tables according to results from cluster analysis

8 visualizzazioni (ultimi 30 giorni)
I am trying to re-sort a data table according to the output from hierarchical clustering.
That is, I have a table with 24 observations across 3 parameters (a,b,c):
% a b c
1.34 0.00 0.00
1.96 2.64 2.42
1.47 0.00 0.00
1.28 0.00 0.00
2.51 0.00 0.00
1.87 1.08 0.00
0.00 0.00 1.03
1.30 1.44 1.75
1.90 1.98 2.52
1.82 0.00 0.00
0.00 2.64 0.00
1.03 0.00 0.00
1.28 1.16 1.06
0.00 0.59 0.00
0.88 0.00 0.00
1.31 0.00 0.00
0.94 0.95 0.00
0.45 0.00 0.00
0.00 1.41 0.00
1.04 0.00 1.01
1.21 2.17 0.00
1.63 1.36 1.84
1.97 2.28 2.02
3.26 2.50 3.30
If I compute the hierachical clustering as:
tree = linkage(X,'average','euclidean');
figure()
dendrogram(tree); %produces a hierarchical clustering plot
I get the figure:
To get the order of the leaf nodes I run:
[H,T,outperm]=dendrogram(tree);
and outperm (1x24 double) gives me a vector with the leaf node order:
1 16 4 3 12 15 10 14 18 6 17 7 20 5 11 19 21 2 23 9 8 22 13 24
Now what I want to do is re-order my original table (24X3 double) according to the sequence of this leaf node order. That is:
a b c
1. 1.34 0.00 0.00
16. 1.31 0.00 0.00
4. 1.28 0.00 0.00
3. 1.47 0.00 0.00
.
.
.
13. 1.28 1.16 1.06
24. 3.26 2.50 3.30
Is there a MatLab way to do this other than to manually copy/paste in an excel file?

Risposta accettata

dpb
dpb il 13 Dic 2021
Y=X(outperm,:); % presuming X is the variable guessing from the initial code...

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by