Thread Subject: Finding monthly means/max in a time series

Subject: Finding monthly means/max in a time series

From: Ryan Utz

Date: 19 Nov, 2009 20:18:03

Message: 1 of 8

Hi all,

I have data in a time series that look like this:

1960 11 29 11.7
1960 11 30 11.1
1960 12 1 10
1960 12 2 9.4
1960 12 3 8.9

Where the format is year, month, day and data in a matrix. I need to find some basic stats on the data for each month. I've tried tinkering with codes I've written previously using things like 'find' and 'ismember' functions, but I can't seem to get to the bottom of it. I can easily make a matrix that is the unique year/month combination but can't seem to link these to the actual data to get the basic stats. Any advice?

Thanks,
Ryan

Subject: Finding monthly means/max in a time series

From: Ryan Utz

Date: 19 Nov, 2009 20:26:20

Message: 2 of 8

Also, I am aware of the 'consolidator' function file, but am hoping not to rely on it in order to minimize the number of required working files I'm dealing with.

Subject: Finding monthly means/max in a time series

From: Alan B

Date: 19 Nov, 2009 20:46:40

Message: 3 of 8

"Ryan Utz" <rutz@al.umces.edu> wrote in message <he495r$3nb$1@fred.mathworks.com>...
> Hi all,
>
> I have data in a time series that look like this:
>
> 1960 11 29 11.7
> 1960 11 30 11.1
> 1960 12 1 10
> 1960 12 2 9.4
> 1960 12 3 8.9
>
> Where the format is year, month, day and data in a matrix. I need to find some basic stats on the data for each month. I've tried tinkering with codes I've written previously using things like 'find' and 'ismember' functions, but I can't seem to get to the bottom of it. I can easily make a matrix that is the unique year/month combination but can't seem to link these to the actual data to get the basic stats. Any advice?
>
> Thanks,
> Ryan

You can do something like this to identify the rows of interest:

monthInds = data(:,1)==1960 & data(:,2)==12;

then, to look at the relevant data:

monthMean = mean(data(monthInds,4));

Are you trying to do something more involved than this?

Subject: Finding monthly means/max in a time series

From: Bruno Luong

Date: 19 Nov, 2009 21:01:19

Message: 4 of 8

Use UNIQUE (on the columns year/mont) + ACCUMARRAY on the index.

Bruno

Subject: Finding monthly means/max in a time series

From: Ryan Utz

Date: 19 Nov, 2009 21:48:18

Message: 5 of 8

I'm trying to do this on 40+ years, so was hoping to get stats (mean, min, max) on each month. So I guess yes, I was looking for something kind of complex. I have used accumarray before... but thought it just summed the data of interest (i.e. accumulate). Can it be used to find basic stats, too?

Subject: Finding monthly means/max in a time series

From: Bruno Luong

Date: 19 Nov, 2009 21:58:20

Message: 6 of 8

"Ryan Utz" <rutz@al.umces.edu> wrote in message <he4ef2$3jv$1@fred.mathworks.com>...
>. I have used accumarray before... but thought it just summed the data of interest (i.e. accumulate). Can it be used to find basic stats, too?

Yes, just pass a function handle that accomplishes whatever stat you need.

Bruno

Subject: Finding monthly means/max in a time series

From: TideMan

Date: 19 Nov, 2009 22:25:38

Message: 7 of 8

On Nov 20, 9:18 am, "Ryan Utz" <r...@al.umces.edu> wrote:
> Hi all,
>
> I have data in a time series that look like this:
>
> 1960     11     29      11.7    
> 1960     11     30      11.1    
> 1960     12     1       10      
> 1960     12     2       9.4    
> 1960     12     3       8.9    
>
> Where the format is year, month, day and data in a matrix. I need to find some basic stats on the data for each month. I've tried tinkering with codes I've written previously using things like 'find' and 'ismember' functions, but I can't seem to get to the bottom of it. I can easily make a matrix that is the unique year/month combination but can't seem to link these to the actual data to get the basic stats. Any advice?
>
> Thanks,
> Ryan

Back on 29 Oct you asked the same question.
What was wrong with the suggestions given you back then?
Have you actually tried them?

Subject: Finding monthly means/max in a time series

From: jenya polyakova

Date: 20 Nov, 2009 19:57:04

Message: 8 of 8

I had the same problem. I posted a code a few days ago. Use function myunique
http://www.mathworks.com/matlabcentral/newsreader/view_thread/265613

"Ryan Utz" <rutz@al.umces.edu> wrote in message <he495r$3nb$1@fred.mathworks.com>...
> Hi all,
>
> I have data in a time series that look like this:
>
> 1960 11 29 11.7
> 1960 11 30 11.1
> 1960 12 1 10
> 1960 12 2 9.4
> 1960 12 3 8.9
>
> Where the format is year, month, day and data in a matrix. I need to find some basic stats on the data for each month. I've tried tinkering with codes I've written previously using things like 'find' and 'ismember' functions, but I can't seem to get to the bottom of it. I can easily make a matrix that is the unique year/month combination but can't seem to link these to the actual data to get the basic stats. Any advice?
>
> Thanks,
> Ryan

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com