How to compare cell content with a string in matlab? -


I have a cell array

  & gt; & Gt; D = {'pop1' now I need an array with the result  [0 0 0 0]    / code>  

when I compare elements of D with 'pop3'.

I tried

  & gt; & Gt; D == 'POP3' ??? Undefined function or method 'eq' for the input arguments of type 'cell' can anybody suggest how to do this?   

You can do it

  & gt; & Gt; D = 'pop1', 'pop2', 'pop3', 'pop4', 'pop5', 'pop6') = 'pop1' 'pop2' 'pop3' 'pop4' 'Pop5' 'pop6' & gt; & Gt; Strcmp ('POP3', D) ans = 0 0 1 0 0 0    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -