I teach the introduction to MATLAB classes for all new hires in the Technical Support group at MathWorks. One of the attendees wanted to know how to do a moving average in MATLAB. This can be useful for filtering, or smoothing, noisy data. I realized I had never covered that on the blog, so here we go! I show how to do this from scratch using conv. If you have the Curve Fitting Toolbox, you might want to check out smooth, which adds some fancier smoothing methods.
By
Doug Hull
Doug first used MATLAB in 1994, could not figure it out until he got some help in 1995. He is now dedicated to making sure that no one else wastes a year of their life not knowing MATLAB like he did.
How can I generate a moving average of a series of images of the form ImSer=(x,y,t); t being a time course. The series could eg be 512×512 pixels and 50 times points. The goal is to remove slow movements over time. I would require a way to specifiy a dimenson over which the average should be done. In this case a time average….
How to convolve the 1D array of complex numbers using a Gaussian Kernel?
How can I generate a moving average of a series of images of the form ImSer=(x,y,t); t being a time course. The series could eg be 512×512 pixels and 50 times points. The goal is to remove slow movements over time. I would require a way to specifiy a dimenson over which the average should be done. In this case a time average….
Try this:
im = rand(150,150,50);
mean(im,3)