How can I create a for loop to count letters in a sequence?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
madhan ravi
2018년 11월 19일
편집: madhan ravi
2018년 11월 19일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!