Need vectorized strfind command
1 次查看(过去 30 天)
显示 更早的评论
If constname is 146x4 char array (column vector of 146 4-character strings, I need the following command to return the index number of the string 'M12 '. But it doesn't. strfind doesn't work with arrays of strings. Which command does? My only option right now is a for loop and the strcmp command, which works, but, hey, this is Matlab!
index = strfind(constname,'M12 ')
0 个评论
采纳的回答
Sean de Wolski
2012-1-20
Convert your 146x4 char array to a 146x1 cell array and then use strfind:
A = repmat('friday',146,1);
B = num2cell(A,2);
strfind(B,'fri')
2 个评论
Sean de Wolski
2012-1-20
Great!
Please accept this answer, to mark the question closed.
It does say num2cell takes any type of array.
更多回答(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!