Find command in matlab

119 Views Asked by At

If I have

i=find(10==[11 15 10 -7])

then i=3. But in the case

i=find(10==[11 15 11 -7])

then "ind=[](1x0)"

I neet to use the output of find command just when is a number, so I can't use

if find(10==[11 15 11 -7])==[]
   'this is not working'
end

How can I decide if the output is not "[](1x0)"?

1

There are 1 best solutions below

0
On BEST ANSWER

I hope it can help you:

1) ismember():

if ~ismember(10,[11,15,11,-7])
   'this is not working' 
end

2) sum(find())

if ~sum(find(10==[11,15,11,-7]))
   'this is not working'  
end

3) isempty(find())

if isempty(find(10==[11,15,11,-7])) 
   'this is not working' 
end