MATLAB: How to get average of interval from matrix

matrix

There's this data [1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,19,20….1000]
From here, [1,2,3,4], [2,3,4,5], [3,4,5,6], and [4,5,6,7] I want to go forward one by one and get the average of the interval (4 intervals).
For example, in this way [2.5, 3.5, 4.5, 5.5 …… 998.5]
How do I make it?

Best Answer

conv(data,[1,1,1,1]/4,'valid')
or
movmean(data,4,'Endpoints','discard')
Related Question