MATLAB: Cell array without empty variables

cell arraycell arrays

I need to create a new cell array using values from another, but excluding the empty values for example… [] 2 [] 1 I would like to have a new a cell array that only includes the 2 and the 1 and skip the empty values. so the final would just read…2 1

Best Answer

This works:
Cell_1 = {[], 2, [], 1};
Cell_2 = Cell_1(cellfun(@(x) ~isempty(x), Cell_1))