finding all the other elements of a cell vector apart from zeros and empties

Dear all,
I want to find all the elements of a cell vector apart from zeros and empties Using the command
ismember(mm,setdiff(mm,'0' ))
I find all the elements apart from zeroes. But I want to find all the elements apart from zeroes AND empty cells. Note mm is a cell of dimension 1000 by 1
thanks

1 Comment

can you post a small snipet of 'mm'. You say it is a cell but does it contain numbers and characters or just numbers..

Sign in to comment.

 Accepted Answer

mm( ~ cellfun( @(C) isempty(C) || (ischar(C) && strcmp(C, '0')), mm ) )

4 Comments

thank you walter. It works. the only problem is that I need to combine this criterion with others like
mm( ~ cellfun( @(C) isempty(C) || (ischar(C) && strcmp(C, '0')), mm ) ) & strcmp(mdata1(:,6),'b1')
in which case your code does not work
mm( ~ cellfun( @(C) isempty(C) || (ischar(C) && strcmp(C, '0')), mm ) & strcmp(mdata1(:,6),'b1') )

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!