Compute arbitrary function in sliding window

This function quickly computes an arbitrary function on a sliding window.
Aktualisiert 1 Sep 2016

Lizenz anzeigen

This function can compute any function which operates on column-oriented data over a sliding centered window on column-vector data. It is vectorized and thus trades memory-usage for speed.
For small window sizes this outperforms functions like SMOOTH. But it is not just a fast moving average. You can specify any function handle that operates on column-oriented data and produces a scalar output, e.g. median, std, prctile (with a scalar 'p'), range, min, sum. But you could also create your own function. For example the (quite obscure) function handle
@(X) all(bsxfun(@gt,X(ceil(size(X,1)/2),:),X(1:floor(size(X,1)/2),:)),1) &
will return a logical array indicating local maxima over a given window size reporting only the first maximum at plateaus.

Zitieren als

David J. Mack (2024). Compute arbitrary function in sliding window (, MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2010a
Kompatibel mit allen Versionen
Windows macOS Linux
Mehr zu ECG / EKG finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise

Updated description.