The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.