detecting no. of events
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Heartrin
am 5 Nov. 2015
Kommentiert: Heartrin
am 5 Nov. 2015
I have an array of 2000x1 = D .
i have a condition D>25. for D>25 higher than 20 sec i should count 1 event.
how can i do this in matlab?
0 Kommentare
Akzeptierte Antwort
Thorsten
am 5 Nov. 2015
Bearbeitet: Thorsten
am 5 Nov. 2015
If D contains an entry every second, you can use:
D = randi(2000, 1, 20); % sample data
di = diff([0 D > 25 0]);
i1 = find(di == 1);
i2 = find(di == -1);
Nevents = nnz(i2 - i1 > 20);
3 Kommentare
Thorsten
am 5 Nov. 2015
What's the size of D? If it is 20000x1 as you said in your original post, then it should work. If it is 1x20000, you have to use
di = diff([0; D > 25; 0]);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!