Is there a method to extract all the data from a nested cell array when each nested cell is of a different size?

조회 수: 3 (최근 30일)
For example
1x1 cell
1x2 cell
1x19 cell
1x20 cell
This will produce a ragged array but is there a work around

채택된 답변

Konstantinos Sofos
Konstantinos Sofos 2015년 6월 12일
Hi George,
My first thought would be to apply a recursive function using the cellfun . e.g.
function C =extractmycells(C)
if iscell(C)
C = cellfun(@extractmycells, C, 'UniformOutput', 0);
C = cat(2,C{:});
else
C = {C};
end
end
As an example
>> B = {1,{2},{3,4,5},{6,7,8,9}}
B =
[1] {1x1 cell} {1x3 cell} {1x4 cell}
>> C =extractmycells(B)
C =
[1] [2] [3] [4] [5] [6] [7] [8] [9]
Regards,

추가 답변 (0개)

카테고리

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