MATLAB: Number of elements in cell array

cell arraycell arraysnumber of elementsnumel

Consider following code and I want find total number of elements in a. I want the answer to be 17.
a = {2};
a(2) = {magic(4)};

Best Answer

sum(cellfun('prodofsize',a))
it gets more complicated when a contains other cell arrays.