Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!v18g2000vbc.googlegroups.com!not-for-mail
From: TideMan <mulgor@gmail.com>
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)
Organization: http://groups.google.com
Lines: 30
Message-ID: <311d6cf8-a071-4c51-804e-7af0e36d2747@v18g2000vbc.googlegroups.com>
References: <hu6ca4$6p$1@fred.mathworks.com> <f97cec95-f9ec-41a2-840b-76de084de454@y18g2000prn.googlegroups.com> 
	<83ae6706-488d-4f66-ba0a-56dff8392379@11g2000prv.googlegroups.com> 
	<hu6gh4$e3t$1@fred.mathworks.com>
NNTP-Posting-Host: 202.78.152.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1275515172 15879 127.0.0.1 (2 Jun 2010 21:46:12 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 2 Jun 2010 21:46:12 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: v18g2000vbc.googlegroups.com; posting-host=202.78.152.105; 
	posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
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:1.9.2.3) 
	Gecko/20100401 Firefox/3.6.3,gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:641635

On Jun 3, 8:56 am, "Li " <liqingji...@gmail.com> 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 <mul...@gmail.com> wrote in message <83ae6706-488d-4f66-ba0a-56dff8392...@11g2000prv.googlegroups.com>...
> > 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:
t=datenum(A(:,1:6));
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.