Search code examples
matlabrowscell-array

How to calculate the number of rows in a Cell array in MATLAB


I want to calculate the number of rows in a Cell array in MATLAB. I use the code below to count the number of columns in a cell array but I do not know its way for counting the rows.

filledCells = ~cellfun(@isempty,a);
columns = sum(filledCells,2)

As an example, i've got x as a cell array:

x =     [5]    [1x8 double]    [5]

This cell array has one row and three columns. I need a code to calculate the number of rows equal to "1" , but I did not find a way to calculate it.


Solution

  • I used most of ideas but it did not work then with the help of what herohuyongtao said i reach to this idea which worked properly

     [nr,nc]=size(x)
    

    Which nr is the number of rows thanks all of you.