How many zeros do I have before a specific sting variable?
조회 수: 1 (최근 30일)
이전 댓글 표시
Dear all
I have
A={
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
' b1'
' b1'
' b1'
' b1'
' b1'
'b1'
' b1'
[0]
[0]
[0]
'b1'
' b1'}
I have this cell vector. This vector has a characteristic. Immediately after the first zeros the letter 'b1' begins. So I would like to count the zeros before the first 'b1' that starts to appear in this vector. In this case I have 39 zeros. Is it possible to calculate this number using a Matlab code?
thanks
댓글 수: 0
채택된 답변
추가 답변 (3개)
Oleg Komarov
2012년 8월 15일
Another solution:
pos = strfind([A{:}],'b')-1
pos(1)
댓글 수: 2
Andrei Bobrov
2012년 8월 16일
Hi Oleg! may be in this case so?
pos = strfind([A{:}],' ')-1
pos(1)
참고 항목
카테고리
Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!