Search code examples
stringmatlabcell

Matlab, find string in cell


I want to find the string in cell. I use this code but i receive an error. Is there any other method?a is a cell array and b is an element of cell matrix.

b(1,1)='kkkkk'

d=strfind(a,b(1,1));

but when I used the following code it worked.

d=strfind(a,'kkkkk');

any idea?

Thanks.


Solution

  • To get and set the contents of a cell, use {} instead of ().

    b{1,1}='kkkkk' 
    
    d=strfind(a,b{1,1}));