Suppose I have a cell array which looks like this:

C =

[] [] []

[] [] [3x3 double]

[] [] []

How can I get all the empty cells using as few commands as possible? Well, the answer is …

`cellfun(@isempty, C)`

So, `cellfun`

is a function that applies a function (`isempty`

here) to each cell of a cell array (`C`

here). If you enjoy general Matlab functions that implicitly apply to each element of an array (say, `sqrt(M)`

does the square roots to all the elements of `M`

), then you must also enjoy this `cellfun`

function that applies an arbitrary function to each element of a cell array. Check it out!

Advertisements

Just what I needed. Embarrassed I didn’t think of it myself. Thanks!

Very Nice Solution!!! Thanks