MATLAB: Index position of the 1

cell arraylogical?

Hi,
I have the following cell array
TEST = [1] [] [] [0] []
I want to get the index position of the 1 not the 0. thanks 🙂 !

Best Answer

find( cellfun(@(C) numel(C) == 1 && C == 1, TEST) )
In the special case where each entry is only empty or a scalar, then
find( cellfun(@(C) C == 1, TEST) )
If you want to find a 1 anywhere in the cell:
find( cellfun(@(C) any(C == 1), TEST) )