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

3 次查看(过去 30 天)
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 ?

采纳的回答

David Hill
David Hill 2020-4-17
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;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by