I\'ve got a vector and I want to calculate the moving average of it (using a window of width 5).
For instance, if the vector in question is [1,2,3,4,5,6,7,8]>
[1,2,3,4,5,6,7,8]>
If you want to preserve the size of your input vector, I suggest using filter
filter
>> x = 1:8; >> y = filter(ones(1,5), 1, x) y = 1 3 6 10 15 20 25 30 >> y = (5:end) y = 15 20 25 30