neat stacking of array and cell array

조회 수: 28 (최근 30일)
EldaEbrithil
EldaEbrithil 2020년 9월 3일
댓글: EldaEbrithil 2020년 9월 3일
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!!

채택된 답변

Stephen23
Stephen23 2020년 9월 3일
편집: Stephen23 2020년 9월 3일
Where C is your cell array:
D = C.';
D(cellfun(@isempty,D)) = []; % not actually required: try without it!
M = vertcat(D{:})
  댓글 수: 1
EldaEbrithil
EldaEbrithil 2020년 9월 3일
Hi Stephen
Perfect as always, thank you very much!!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

madhan ravi
madhan ravi 2020년 9월 3일
C = reshape(cell_array.', [], 1);
C(cellfun('isempty', C)) = []

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by