Using strfind to find character index in word

2 ビュー (過去 30 日間)
Dylan Warman
Dylan Warman 2019 年 9 月 16 日
回答済み: Walter Roberson 2019 年 9 月 16 日
hi, i have a script where i must find the index of the letter e in the word each
Guess1 = e;
HangWord = "each"
index = strfind(HangWord, 'Guess1')
this returns index=[]
thank you

回答 (2 件)

Stephen23
Stephen23 2019 年 9 月 16 日
>> HangWord = 'each';
>> Guess1 = 'e';
>> index = strfind(HangWord, Guess1)
index = 1

Walter Roberson
Walter Roberson 2019 年 9 月 16 日
Guess1 = 'e';
HangWord = "each";
index = strfind(HangWord, Guess1);

カテゴリ

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