how I can transform matrices into a single matrix? I have 20 - 6x6 matrices, and I need to create 1 matrix for cluster analysis. Thanks!

5 Kommentare

KSSV
KSSV am 6 Okt. 2016
what dimension of matrix you want at the end?
luca buonocore
luca buonocore am 6 Okt. 2016
20 rows and 6 columns, so 20x6!
Marc Jakobi
Marc Jakobi am 6 Okt. 2016
If you have 20 6x6 matrices, that's a total of 20*6*6 values = 720 values. In an output with 20 rows and 6 columns, you can only fit 120 values. Are you sure you want a 20x6 matrix?
luca buonocore
luca buonocore am 6 Okt. 2016
I need to do a hierchical clustering on 20 values, but each values is a 6x6 matrix, so in the end I must clustering returning all 20 values. How I can do that?
KSSV
KSSV am 6 Okt. 2016
Whats is the criteria for hierchical clustering..

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Massimo Zanetti
Massimo Zanetti am 6 Okt. 2016
Bearbeitet: Massimo Zanetti am 6 Okt. 2016

3 Stimmen

You need to assign each variable to only one row of all_data matrix.
A= [ 1 2 3; 4 5 6; 7 8 9];
B= [10 11 12; 13 14 15; 16 17 18];
C= [19 20 21;22 23 24; 25 26 27];
D= [28 29 30; 31 32 33; 34 35 36];
E= [37 38 39; 40 41 42; 43 44 45];
F= [46 47 48; 49 0 51; 52 53 54];
all_data = [A(:)';B(:)';C(:)';D(:)';E(:)';F(:)']
Y= pdist(all_data);
Z = linkage(Y,'ward');
H = dendrogram(Z,'Orientation','left','ColorThreshold','default');
set(H,'LineWidth',1)

Weitere Antworten (1)

elias GR
elias GR am 6 Okt. 2016

0 Stimmen

Make a 3D matrix. If your 6x6 matrices are in the variables A1,A2,...,A20, then:
A=zeros(6,6,20);
A(:,:,1)=A1;
A(:,:,2)=A2;
...
A(:,:,20)=A20;
At the end all the matrices are inside 1 matrix as you wished, A.

3 Kommentare

luca buonocore
luca buonocore am 6 Okt. 2016
very elegant... but I need to do hierarchical clustering with this matrix, how I can convert into a 2D matrix?
elias GR
elias GR am 6 Okt. 2016
Give us a specific numerical example of what you need
I have 3 matrices:
A= [ 1 2 3; 4 5 6; 7 8 9];
B= [10 11 12; 13 14 15; 16 17 18];
C= [19 20 21;22 23 24; 25 26 27];
I need to do hierarchical clustering on this variables, and i tried this:
all_data = [A;B;C];
Where (A,B,C) are variables
Y= pdist(all_data)
Z = linkage(Y,'ward');
H = dendrogram(Z,'Orientation','left','ColorThreshold','default');
set(H,'LineWidth',1)
but MATLAB give me more than 3 values, but I need 3 values back, and no more...
How I can do this?

Melden Sie sich an, um zu kommentieren.

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by