MATLAB: How to remove the empty cells from a vector of cells

cell arraysMATLABstrings

I have a vector of cells which contain strings. Some of the cells in the vector are empty. I want to remove the empty cells from the vector.
Suppose I start with
strs = {'one','','two','three','','','four',''};
and I want to end with
strs = {'one','two','three','four'};

Best Answer

The built-in function strcmp can compare a character array to a cell array of strings. Matching cells may be removed by setting them equal to the empty array.
strs(strcmp('',strs)) = [];