To search for an empty char cell array in a cell array, you can use logical indexing in MATLAB. Here's an example:
319 chars10 lines
In the above code, we first create a cell array called myCellArray
with a mix of empty and non-empty char cells. We then use the cellfun
function to generate a logical array emptyCharCells
that represents which elements in myCellArray
are empty char cells. We then use the find
function to retrieve the indices of these empty char cells. Finally, we use logical indexing to retrieve the actual values of these empty char cells in the emptyCharCellsValues
variable.
Note that the && ischar(x)
condition in the cellfun
call is necessary to ensure that only empty char cells are selected. Without it, empty non-char cells would also be selected.
gistlibby LogSnag