How can I create a for loop to count letters in a sequence?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
madhan ravi
il 19 Nov 2018
Modificato: madhan ravi
il 19 Nov 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!