From: TideMan <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to average column values to the same minute?
Date: Wed, 2 Jun 2010 14:46:12 -0700 (PDT)
Lines: 30
Message-ID: <>
References: <hu6ca4$6p$> <> 
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: 1275515172 15879 (2 Jun 2010 21:46:12 GMT)
NNTP-Posting-Date: Wed, 2 Jun 2010 21:46:12 +0000 (UTC)
Injection-Info:; posting-host=; 
User-Agent: G2/1.0
X-HTTP-Via: 1.1 bc8
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: 
	Gecko/20100401 Firefox/3.6.3,gzip(gfe)
Xref: comp.soft-sys.matlab:641635

On Jun 3, 8:56 am, "Li " <> wrote:
> Thanks, but I am afraid that it does not solve my problem. I have millions of data from 1900 all the way to 2010. The number of measurements within a minute ranging from 1 to 20. I do not think it is simply a reshape and average. What I want are the averages within each minute, instead of the average of the whole time span.
> TideMan <> wrote in message <>...
> > Oh, I see.........
> > I misread the headers.
> > A1=reshape(A(:,6),12,[]);  % Form a 12xn matrix
> > Abar=mean(A1).';   % Take the mean of each column and transpose
> > Note: the no of rows in the matrix A must be a multiple of 12 or you
> > must reduce it to that.

You said the data were at 5 sec interval and I assumed you were
telling the truth.
Now you tell us they are at intervals between 5 and 60 seconds.

A different strategy is needed when the data are not equispaced.
Here's one method:
1.  Convert the times to Matlab days:
2.  Use histc to split the time into equispaced bins of 5 min.
3.  Use the second argument of histc to determine which bin each A(:,
7) belongs to and loop to calculate the mean in each bin.