Matlab Remove empty cell array content -
i have 5*14 matrix (m*n)
m={'a','b',.....' ',' ' ; 'aa','bb',...' ',' ' ; ... }
whats best option remove empty cells (5*n) after removing empty cells:
m={'a','b','c'; 'aa','bb' ; 'e'; 'aa','xx'; ...}
when this:
emptycells = cellfun('isempty', m); cols = size(m,2); m(emptycells) = []; m = reshape(m, [], cols);
i error :error using reshape product of known dimensions, 14, not divisible total number of elements, 52.
here solution creating nested cell:
m={'a','b','c';'d','e','';'','','';'','f',''}; %convert cell nested cell m=mat2cell(m,ones(size(m,1),1)); %now apply code every subcell ix=1:numel(m) emptycells = cellfun('isempty', m{ix}); m{ix}(emptycells)=[]; end
Comments
Post a Comment