Using strfind to find character index in word

2 visualizaciones (últimos 30 días)
Dylan Warman
Dylan Warman el 16 de Sept. de 2019
Respondida: Walter Roberson el 16 de Sept. de 2019
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

Respuestas (2)

Stephen23
Stephen23 el 16 de Sept. de 2019
>> HangWord = 'each';
>> Guess1 = 'e';
>> index = strfind(HangWord, Guess1)
index = 1

Walter Roberson
Walter Roberson el 16 de Sept. de 2019
Guess1 = 'e';
HangWord = "each";
index = strfind(HangWord, Guess1);

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by