MATLAB Answers

Find smallest cell in cell array

28 views (last 30 days)
Is there a way to find the smallest sized cell in a cell array?
Thanks!

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Apr 2012
What is "size" in this context? Number of rows? Number of columns? Number of elements? Storage requirement?
Which is smaller:
'fdoafodsif-0dsi0-0-dfs0-fds0--ds'
or
struct('foo',3,'bar',7)
?

  4 Comments

Show 1 older comment
Walter Roberson
Walter Roberson on 19 Apr 2012
[minsize, minidx] = cellfun(@(C) size(C,2), YourCell);
Philip
Philip on 19 Apr 2012
That worked perfectly, thanks so much!
Jan
Jan on 19 Apr 2012
Or slightly faster:
[minsize, minidx] = min(cellfun('size', YourCell, 2));

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by