Reputation: 303
For example I have a:
1x11 cell
[] [] 3 [] [] [] [] [] 1 [] []
How can I do to find coordinates of cells non empty?
like res=[1,3;1,9]
Upvotes: 1
Views: 44
Reputation: 112659
Apply the function isempty
to each cell's contents via cellfun
, and then get the column and row indices of the cells that gave false
(that is, were not empty) using the two-output version of find
:
x = {[] [] 3 [] [] [] [] [] 1 [] []}
[ii, jj] = find(~cellfun(@isempty, x))
res = [ii(:) jj(:)];
Upvotes: 3