Find the different elements in a cell array

3 views (last 30 days)
LL
LL on 23 Nov 2021
Commented: LL on 29 Nov 2021
Hi to all,
i have a problem because i have a cell array and i need to find the cells that contain both numbers 1 and 2.
Thanks.

Accepted Answer

Stephen23
Stephen23 on 23 Nov 2021
Edited: Stephen23 on 23 Nov 2021
Where out is your cell array:
fnh = @(v) any(v(:)==1)&&any(v(:)==2);
idx = cellfun(fnh,out)
  12 Comments
LL
LL on 29 Nov 2021
So for example in the rows 6-7 and colums 8-9 i have three cells not empty the result that i would like to obtain is like this.

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!