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: Henk Borsje
Subject: RE: Taking a mean of a fixed length number of points
Date: Sat, 30 Nov 2019 10:21:38 +0100

Here is a simple example:

 

n = 1000000;

m = 10;

k = 5;

a = rand(n,m);

tmp = reshape(a,k,[],m);

size(tmp)

aavg = reshape(mean(tmp),[],m);

size(aavg)

aavg(1,1)

mean(a(1:k,1))

 

Henk Borsje

 

 

From: Nicholas Jankowski <address@hidden>
Sent: Saturday, November 30, 2019 2:50 AM
To: Henk Borsje <address@hidden>
Cc: Help GNU Octave <address@hidden>
Subject: Re: Taking a mean of a fixed length number of points

 

On Fri, Nov 29, 2019 at 4:12 PM Henk Borsje <address@hidden> wrote:

This question is not of crucial importance, but I’m curious if there is a better alternative.

 

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 wonder if there is a simpler or more direct way, except for substituting equation (1) into (2)

 

 

just for clarity, can you give a brief example of what your input looks like and what you would like the output to look like?  it seems your method is fairly compact. 


reply via email to

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