- strfind
- ismember
- contains
Is there a dsearchn equivalent for strings?
1 次查看(过去 30 天)
显示 更早的评论
I have two cell arrays, one is the array I want to find indices of multiple strings. Say q = { 'A', 'B' } and p = { 'H', 'F', ..., 'Z' }. Is there a function that finds the strings and returns their indices like ans = [ 12, 3 ] ? Or the only way is to use a for loop and find(strcmp(...)) which doesn't seem very efficient?
0 个评论
采纳的回答
Cris LaPierre
2020-8-27
I think you would have to do it one value at a time.
find(contains(p,q(1)))
There are several functions you could use
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!