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!