How can I get Matlab to check for a specific string and show it's location?

2 ビュー (過去 30 日間)
Surafel Taddesse
Surafel Taddesse 2019 年 7 月 10 日
編集済み: Geoff Hayes 2019 年 7 月 11 日
Lets say I have the following:
A = [a1,a2,a3,a11,a22,a33]
When I say
Index = strfind(A,'a1')
Matlab tells me that there are 2 a1 because it considers the a11 as well. Same for a2 or a3.
How can I specify that I want a1 only.
I appriciate the help.

採用された回答

Geoff Hayes
Geoff Hayes 2019 年 7 月 11 日
Surafel - use strcmp instead
>> A = {'a1','a2','a3','a11','a22','a33'};
>> result = strcmp(A,'a1')
result =
1 0 0 0 0 0

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by