Kevin Dong
Kevin Dong

Reputation: 5349

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.

Upvotes: 0

Views: 45

Answers (1)

heriantolim
heriantolim

Reputation: 457

It's simple:

cellfun(@numel,mat)

Upvotes: 1

Related Questions