Borrar filtros
Borrar filtros

neat stacking of array and cell array

17 visualizaciones (últimos 30 días)
EldaEbrithil
EldaEbrithil el 3 de Sept. de 2020
Comentada: EldaEbrithil el 3 de Sept. de 2020
Hi all
i have this 3x2 cell array:
6x1 cell 1x1 cell %a
1x1 cell 1x1 cell %b
[] 1x1 cell %c
i want to stack up the cell array in this way:
6x1 cell
1x1 cell %a
1x1 cell
1x1 cell %b
[]
1x1 cell %c
then i want to remove the empty cell and expand the 5x1 cell in a matrix.
i have tried with vertcat but it doesn't keep the order...
Thank you for the help
Regard!!

Respuesta aceptada

Stephen23
Stephen23 el 3 de Sept. de 2020
Editada: Stephen23 el 3 de Sept. de 2020
Where C is your cell array:
D = C.';
D(cellfun(@isempty,D)) = []; % not actually required: try without it!
M = vertcat(D{:})
  1 comentario
EldaEbrithil
EldaEbrithil el 3 de Sept. de 2020
Hi Stephen
Perfect as always, thank you very much!!

Iniciar sesión para comentar.

Más respuestas (1)

madhan ravi
madhan ravi el 3 de Sept. de 2020
C = reshape(cell_array.', [], 1);
C(cellfun('isempty', C)) = []

Categorías

Más información sobre Cell 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!

Translated by