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
Re: average of sections of an array
Posted: Oct 20, 2012 7:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <k5tv44$8pf$1@newscl01ah.mathworks.com>...
> "Daniel Robbins" <d.w.e.robbins@gmail.com> wrote in message <k5tthg$3nb$1@newscl01ah.mathworks.com>...
> > 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]?

>
> a = [9 9 9 6 6 6 3 3 3]
> b = mean(reshape(a,3,[]),1)
>
> % Bruno


Works perfectly, thanks Bruno.



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.