How do I find the number of occurrences of data points between specified values in a matrix?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to find the interval of data point occurrences in a 1x40 matrix.
given:
x=[1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 3 3 4 5 6 1 2 2 2 2 2 2 2 2 2 2 2 3 4 1 2 2 2 2 2];
I want to find the number of values between the 1's found in this data set. The output should say how many occurrences of "1" exist (4) and the number of data points that occur before the next "1" in sequence. For example, between the first and second "1" =9, between the second and third "1=9", between the third and fourth "1"=13.
Any help would be appreciated!
0 Commenti
Risposta accettata
Andrei Bobrov
il 8 Dic 2015
Modificato: Andrei Bobrov
il 8 Dic 2015
t = x == 1;
out = diff(find(t))-1;
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical 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!