Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: average of sections of an array
Replies: 2   Last Post: Oct 20, 2012 7:08 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Daniel Robbins

Posts: 27
Registered: 6/12/12
average of sections of an array
Posted: Oct 20, 2012 6:14 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.