我有5 * 14矩阵(m * n)
<html>
<body>
<script src="hello.js"></script>
</body>
</html>
删除空单元格后删除空单元格为(5 * n)的最佳选择:
M={'a','b',.....' ',' ' ;
'aa','bb',...' ',' ' ;
... }
当我这样做时:
M={'a','b','c';
'aa','bb' ;
'e';
'aa','xx';
...}
我收到错误:emptyCells = cellfun('isempty', M);
cols = size(M,2);
M(emptyCells) = [];
M = reshape(M, [], cols);
答案 0 :(得分:0)
以下是创建嵌套单元格的解决方案:
M={'a','b','c';'d','e','';'','','';'','f',''};
%Convert cell to nested cell
M=mat2cell(M,ones(size(M,1),1));
%now apply your code to every subcell
for ix=1:numel(M)
emptyCells = cellfun('isempty', M{ix});
M{ix}(emptyCells)=[];
end