how to do running mean?

2 views (last 30 days)
Lilya on 22 Oct 2020
Commented: Lilya on 25 Oct 2020
Hi all,
I have a 3d matrix with a dimension of 21*41*273, for which I want to do the running mean over the third dimension (273 days) for every 4 days.
Any help would be appreciated.

Accepted Answer

Ameer Hamza
Ameer Hamza on 22 Oct 2020
Try something like this
M = rand(21, 41, 273);
M_new = movmean(M, [0 3], 3, 'Endpoints', 'discard');
M_new = M_new(:,:,1:4:end);
Lilya on 25 Oct 2020
Thank you!

Sign in to comment.

More Answers (0)


Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!