How many zeros do I have before a specific sting variable?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Più risposte (3)
Oleg Komarov
il 15 Ago 2012
Another solution:
pos = strfind([A{:}],'b')-1
pos(1)
2 Commenti
Andrei Bobrov
il 16 Ago 2012
Hi Oleg! may be in this case so?
pos = strfind([A{:}],' ')-1
pos(1)
Vedere anche
Categorie
Scopri di più su Operators and Elementary Operations 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!