How can I create a for loop to count letters in a sequence?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fope Ayo
el 19 de Nov. de 2018
Comentada: Fope Ayo
el 19 de Nov. de 2018
i have the following sequence
a = b c d b c d e c c d b c b e e
i want to create a for loop to identify the number of b’s and c’s in the sequence?
help please
0 comentarios
Respuesta aceptada
madhan ravi
el 19 de Nov. de 2018
Editada: madhan ravi
el 19 de Nov. de 2018
No loops needed:
a = 'b c d b c d e c c d b c b e e'
no_of_bs=sum(ismember(a,'b'))
no_of_cs=sum(ismember(a,'c'))
3 comentarios
madhan ravi
el 19 de Nov. de 2018
Thanks Guillaume , what was I thinking , you are absolutely right!
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!