How do I detect empty cells in a cell array? I know the command to remove the empty cell is a(1) = []
, but I can't seem to get MATLAB to automatically detect which cells are empty.
Background:
I preallocated a cell array using a=cell(1,53)
.
Then I used if exist(filename(i))
and textscan to check for a file, and read it in. As a result, when the filename(i)
does not exist, an empty cell results and we move onto the next file.
When I'm finished reading in all the files, I would like to delete the empty cells of a
. I tried if a(i)==[]