MATLAB: Generating a vector containing the sizes of all cells of a cell array, along a specific dimension

size cell array cellfun dimension

Is there a way to vectorize this? (I tried with "cellfun", but did not succeed).
for i = 1:numel(a)
s(i) = size(a{i}, 1);
end
Where a sample of "a" is provided in attachment.

Best Answer

  • Does this give what you want?
    s = cellfun(@(x)size(x,1),a);