help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Taking a mean of a fixed length number of points


From: Francesco Potortì
Subject: Re: Taking a mean of a fixed length number of points
Date: Tue, 03 Dec 2019 10:55:21 +0100

>I need to calculate the columnar average of each k points out of an array of
>x(n,m) elements, resulting in a new array  x_avg (floor (n/k) , m) elements.
>
>I use:
>        tmp = reshape(x,k,[],m);                          (1)
>        x_avg = reshape(mean(tmp),[],m);                  (2)

I think that what you use is the simpler and most efficient way.  Rather
than resorting to 3-d arrays, I'd go columnar, by removing the fourth
argument in (1), which is cleaner to my eyes.

-- 
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(gate 20, 1st floor, room C71)         Web:    http://fly.isti.cnr.it




reply via email to

[Prev in Thread] Current Thread [Next in Thread]