How to delete empty rows from string arrays contained in a cell array?
조회 수: 7 (최근 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!