Is there a method to extract all the data from a nested cell array when each nested cell is of a different size?
2 次查看(过去 30 天)
显示 更早的评论
For example
1x1 cell
1x2 cell
1x19 cell
1x20 cell
This will produce a ragged array but is there a work around
1 个评论
Walter Roberson
2015-6-12
What would you want the output to look like?
Are all the elements either cell or numeric?
采纳的回答
Konstantinos Sofos
2015-6-12
Hi George,
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,
1 个评论
Kazi Alam
2021-6-11
What if I would like continue every time with a new row?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!