how to count number of values exceeding given threshold in moving window

1 vue (au cours des 30 derniers jours)
riki ragùa
riki ragùa le 18 Fév 2018
Commenté : riki ragùa le 18 Fév 2018
I want to calculate # of values exceeding specified threshold (m) with a moving window of length w (so that we omit the 1st sample and add another sample) I have a data of 1500 samples. In matlab r2013 thanx

Réponse acceptée

Guillaume
Guillaume le 18 Fév 2018
If I understood correctly:
v = [1 2 3 4 5 6 5 4 3 2 1 2 3 4 5 6]; %demo data
threshold = 4;
windowsize = 5;
abovethreshold = v > threshold;
inwindowabovethreshold = conv(abovethreshold, ones(1, windowsize), 'same')
If you were using R2016a or later, you could use movsum instead of the awkward convolution.
  5 commentaires
Image Analyst
Image Analyst le 18 Fév 2018
Same answer I would have given. If it solves your problem, you can "Accept this answer", and vote for it, to thank Guillaume by giving him reputation points.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by