Assign moving window average if 50 % of the values in the window are within a threshold

4 vues (au cours des 30 derniers jours)
Hi,
While doing a moving window average, if the 50 % values in that window are less than a certain threshold, how can one assign NaN to the average over that window.
mvavg = movmean(temp_ms, [left_window right_window],'omitnan',...
'Endpoints', 'discard');
How should I check for the threshold over the window ?
  1 commentaire
darova
darova le 17 Avr 2020
What about this?
a = [1 2 3 4 4 0 2 1]
a>3
And the result
a =
1 2 3 4 4 0 2 1
ans =
0 0 0 1 1 0 0 0

Connectez-vous pour commenter.

Réponse acceptée

David Hill
David Hill le 17 Avr 2020
threshold=5;%whatever you want your threshold to be
threshold2= ;%window size/2
mvavg = movmean(temp_ms, [left_window right_window],'omitnan',...
'Endpoints', 'discard');
mvsum = movsum(temp_ms<threshold, [left_window right_window],'omitnan',...
'Endpoints', 'discard');
mvavg(mvsum<threshold2)=nan;

Plus de réponses (0)

Catégories

En savoir plus sur NaNs 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