matlab - How do I detect empty cells in a cell array? -


How do I find empty cells in a cell array? I know that the command to remove an empty cell is a (1) = [] , but I think that which cells are empty, can not get MATLAB to automatically detect .

Background: I have already specified a cell table using the a = cell (1,53) . Then i if exists (file name (i)) and textscan to check for a file, and read it, as a result, when filename (i) does not Exists, an empty cell result and we move to the next file

When I finish reading all the files, then I would like to delete the empty cells of a I try if a (i) == []

use

 % # empty cells Search micro cells = cellfun (@ isempty, a); Empty empty cells # empty (emptyCells) = [];  

Note: a (i) == [] will not work if you want to know that the i-th cell is empty, you can see the contents of the cell You have to use curly brackets to reach. In addition, to evaluate == [] instead of true / false , you use the command isempty Instead, in a nutshell: a (i) == [] should be rewritten as isempty (a {i}) .


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -