Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



average of sections of an array
Posted:
Oct 20, 2012 6:14 AM


Does anyone know how to calculate windows of means in a vector?
For example If I have a = [9 9 9 6 6 6 3 3 3] and I want to calculate the means in groups of three I would get b = [9 6 3]?
While for a short vector I could easily write something like:
b=[mean(a(1:3)) mean(a(4:6)) mean(a(7:9))]
The vectors I am working with are long so this becomes tedious, I am guessing there is a better way to script this?
Thanks in advance Dan



