How can I use multidimensional matrices as input for clustering in MATLAB?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SOPAE YI
el 12 de Mzo. de 2020
Comentada: Ameer Hamza
el 13 de Mzo. de 2020
Hi all,
I am trying to cluster 2-dimensional time series signals with a similarity measure (maybe corr2).
For example, suppose I have the following signals (1st column is time, 2nd column is amplitude):
A = [1.2,1.5; 2.4,0.5; 3.2,1.5; 4.1,1.0]
B = [1.0,1.0; 2.0,0; 3.0,1.0; 4.0,0.5]
C = [1.1,1.2; 2.2,1.3; 3.3,1.5; 4.2,1.7]
D = [1.3,1.3; 2.1,1.4; 3.2,1.7; 4.3, 2.0]
E = [1.3,1.8; 2.3,0.4; 3.1,1.6; 4.3,0.8]
After applying a clustering technique, such as K-means (hard partition) or Fuzzy (soft partition) or something else, I am expecting 2 clusters like this:
Cluster 1 (A, B, E: see figure 1) and cluster 2 (C, D: see figure 2)
Plot of A, B, E
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276802/image.jpeg)
Plot of C, D
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276803/image.jpeg)
I have been searching for a way to cluster 2-dimensional matrices but I have not found any MATLAB code I can adopt to cluster my matrices.
How can I use multidimensional matrices like A, B, C, D and E as input for clustering in MATLAB?
0 comentarios
Respuesta aceptada
Ameer Hamza
el 12 de Mzo. de 2020
You can first convert each matrix to a linear array and then apply a clustering algorithm. Since the corresponding element of each matrix have the same unit, so the shape and order of input do not matter to the clustering algorithm. For example,
A = [1.2,1.5; 2.4,0.5; 3.2,1.5; 4.1,1.0];
B = [1.0,1.0; 2.0,0; 3.0,1.0; 4.0,0.5];
C = [1.1,1.2; 2.2,1.3; 3.3,1.5; 4.2,1.7];
D = [1.3,1.3; 2.1,1.4; 3.2,1.7; 4.3, 2.0];
E = [1.3,1.8; 2.3,0.4; 3.1,1.6; 4.3,0.8];
M = [A(:) B(:) C(:) D(:) E(:)]'; % each matrix A,B,...,E is now a row of matrix M
idx = kmeans(M, 2, 'Distance', 'correlation')
result:
idx =
1
1
2
2
1
It identified 1st, 2nd, and 5th row are one cluster, 3rd and fourth are other cluster.
2 comentarios
Ameer Hamza
el 13 de Mzo. de 2020
The clustering algorithm must take data with a consistent dimension, so I am not sure is there an easy way to apply clustering in a situation where the size of input matrices is not equal. Please refer to my comment on your other question to see how you can avoid losing information in matrix B.
Más respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!