how to query string exactly in matlab
5 次查看(过去 30 天)
显示 更早的评论
I have a composition table. If I enter matlab, I will get a cell of n*1
e.g. file attached
If I finish reading matlab
I want to find the location of M2 how can I find it
I have tried using
Index = find(contains(str,'M2'));
But this will output all the components that contain the M2 name
I want to output only the position of an M2
0 个评论
采纳的回答
Stephen23
2022-9-1
编辑:Stephen23
2022-9-1
C = readcell('TEST.xlsx')
X = matches(C,'M2')
or
X = strcmp(C,'M2')
TIP for the future: scroll to the bottom of the CONTAINS documentation page, you will find a list of related functions, including MATCHES and many others. Browsing the MATLAB help is a very useful skill.
1 个评论
Rik
2022-9-1
Another related function: ismember, which is mostly similar in this context to the matches function.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!