Alex Rivera | Logout

How to search for a string in cell array in MATLAB?

Asked 2011-11-09T06:47:52.463
108

Let's say I have the cell array

strs = {'HA' 'KU' 'LA' 'MA' 'TATA'}

What should I do if I want to find the index of 'KU'?

Edit
Report

1 Answer

130

I guess the following code could do the trick:

strs = {'HA' 'KU' 'LA' 'MA' 'TATA'}
ind=find(ismember(strs,'KU'))

This returns

ans = 
     2
answered 2011-11-09T07:04:52.553

Your Answer