I have an cell array
>>D = {'Pop1','Pop2','Pop3','Pop4','Pop5','Pop6'}
Now I need an array with result [0 0 1 0 0 0]
when I compare elements of D with 'Pop3'.
I tried
>> D == 'Pop3'
??? Undefined function or method 'eq' for input arguments of type 'cell'.
Can anybody suggest how to do this?
You can do it by using strcmp
>> D = {'Pop1','Pop2','Pop3','Pop4','Pop5','Pop6'}
D =
'Pop1' 'Pop2' 'Pop3' 'Pop4' 'Pop5' 'Pop6'
>> strcmp('Pop3', D)
ans =
0 0 1 0 0 0