Moving averages / Moving median etc

Calculates moving averages (or median/fun) of a timeseries.
Updated 16 Jun 2011

View License

MOVING will compute moving averages of order n (best taken as odd)

Usage: y=moving(x,n[,fun])
where x is the input vector (or matrix) to be smoothed.
m is number of points to average over (best odd, but even works)
y is output vector of same length as x
fun (optional) is a custom function rather than moving averages

Note:if x is a matrix then the smoothing will be done 'vertically'.


hold on;
legend('x','7pt moving mean','7pt moving median','7pt moving max','location','best')

Cite As

Aslak Grinsted (2024). Moving averages / Moving median etc (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

added Screenshot, updated description

Made more flexible and more robust.