How to delete empty rows from string arrays contained in a cell array?
6 次查看(过去 30 天)
显示 更早的评论
I would need to delete empty strings contained in N x 1 string arrays (N is variable) which are contained in a cell array theirself.
mycellArray is a 3×1 cell array and is made up of string arrays of variable dimensions:
- mycellArray{1} is a 49×1 string array
- mycellArray{2} is a 22×1 string array
- mycellArray{3} is a 35×1 string array
mycellArray{1} looks like:

How can I delete just the empty rows "" and let the written text?
Thanks in advance!
0 个评论
采纳的回答
madhan ravi
2020-7-10
编辑:madhan ravi
2020-7-10
Wanted = arrayfun(@(y)cellfun(@(x) x(~(x=="")), c{y},'un', 0),1:numel(c)).' % c your cell array
3 个评论
更多回答(1 个)
Arthur Roué
2020-7-10
% Logical array, true when element in cell is empty
vb = cellfun(@isempty, MyCell)
% Remove empty element
MyCell = MyCell(~vb)
2 个评论
Arthur Roué
2020-7-10
编辑:Arthur Roué
2020-7-10
Oh, ok I misunderstood the problem.
I think you have your answer below :)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!