Calculating annual means for different time periods
Show older comments
Hello,
I am trying to calculate annual means from monthly data for a number of basins with different time periods.
my data looks something like this:
time (year/month) Amazon Congo .....
195101 6430 4356
195102 2530 7960
195103 1820 2060
..... ..... .....
..... ..... .....
..... ..... .....
200610 16200 NaN
200611 6540 NaN
200612 9870 NaN
and so on. In addition I have two variables specifying the start and end years of the records for each basin as they differ from one basin to another:
start end
195101 200012
195601 199312
197101 200612
..... .....
So my questions is: how can I tell matlab to calculate the mean of each year (mean 195101-195112 and so on) and also tell it to start and end calculations at a particular year depending on the basin?
Cheers, Anna
4 Comments
Anna
on 23 Sep 2011
Artur M. G. Lourenço
on 23 Sep 2011
time = [ 195101; .... 200612 ]
amazon = [ 6430; . . . 9870 ]
for first year of amazon
my1 = mean(amazon(1:12,1))
for second year of amazon
my2 = mean(amazon(13:24,1)) .............. etc
your question is a little confusing but that's what I understood, sorry anything.
Artur M. G. Lourenço
on 23 Sep 2011
in vertical change to
my1 = mean(amazon(1,1:12))
for stop the mean you can use an 'for':
for n = 1:12
my1 = mean(amazon(1,n))
end
Anna
on 23 Sep 2011
Accepted Answer
More Answers (1)
Walter Roberson
on 23 Sep 2011
0 votes
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!