Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Summarizing yearly/monthly data in time series
Date: Wed, 4 Nov 2009 19:41:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 16
Message-ID: <hcslce$e15$1@fred.mathworks.com>
References: <hcaam2$8dv$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257363662 14373 172.30.248.37 (4 Nov 2009 19:41:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 19:41:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:582499


"Ryan Utz" <rutz@al.umces.edu> wrote in message <hcaam2$8dv$1@fred.mathworks.com>...
> Hi all,
> 
> I have a time series dataset that consists of daily data over several years. Most of the analyses are run on a matrix where the first column is the year, the second the month, the third the day and the final column is the data of interest. I want to do some simple summary statistics (sum of the data, for instance) for each month. I was assuming I'd do this in a for-loop.
> 
> Normally, I would identify each unique month using the 'unique' and 'find' commands  in the for-loop but since there is a month AND year I'm not quite sure how to do it. I have figured out that 'find' may include conditionals (i.e. '&') but still can't get to the bottom of it...

May be something like this:

year_selected = 2009;
month_selected = 11;

matched = data(:,1)==selected & data(:,2)==month_selected;
sumdata = sum(data(matched,4))

Bruno