Search code examples
matlabcell-array

Extract the size information of a MATLAB 2D cell array


>> Mat

Mat =

  3×1 cell array

    {1×4 double}
    {1×5 double}
    {1×6 double}

Mat is of type n-by-1 cell array, and each element is of type 1-by-m cell array.

How to extract each element count of a 2D cell array into num without iterations?

>> num

num =

     4
     5
     6

I have tried size and numel, but they do not help.


Solution

  • It's simple:

    cellfun(@numel,mat)