how to cell array all data into a matrices
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
singh
el 29 de Abr. de 2015
Comentada: Star Strider
el 29 de Abr. de 2015
suppose i have a cell array
a={{1,2,3};12;{21,32,43}};
how to get all data in single matrix
b=[1,2,3,12,21,32,43]'
0 comentarios
Respuesta aceptada
Star Strider
el 29 de Abr. de 2015
Editada: Star Strider
el 29 de Abr. de 2015
Use horzcat and cell2mat:
b = cell2mat(horzcat(a{:}))
produces:
b =
1 2 3 12 21 32 43
I didn’t initially see the transpose operator. To get it as a column vector, add the transpose:
b = cell2mat(horzcat(a{:}))'
2 comentarios
Star Strider
el 29 de Abr. de 2015
I wish! Thank you for the compliment.
Slightly different with ‘A’ here, since it is a cell array of vectors and not a cell array of cells, so we do not need cell2mat this time:
B = horzcat(A{:})
produces:
B =
1 2 14 16 19 6 12 15 20 3 4 7 17
Más respuestas (0)
Ver también
Categorías
Más información sobre Multidimensional Arrays 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!