Count number of cells separating two trues in logical vector
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Enrico Gambini
il 12 Ott 2022
Commentato: Enrico Gambini
il 12 Ott 2022
Hello!
I would like to find a fast procedure to count the number of cells separating two trues in a logical vector, and store the results in a new numeric vector.
For instance:
x=[true;false;false;false;true;false;false;true;false;true];
The output should be
output=[4;3;2]; % Hence, it counts also the "first" true
Hope the question is clear.
Thank you!
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Whos 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!