How i can select max value from huge matrix of 30 years daily data

2 views (last 30 days)
Lets say i have daily data for 30 years of period in a matrix. To make it simple just assume it has only 1 column and 10957 row indicates the days for 30 years. The year start in 2010. I want to find the max value for every year so that the output will be 1 column and 30 rows. Is there any automated way to program it in Matlab? currently im doing it manually where what i did was:
%for the first year
max(RAINFALL(1:365);
%for the 30th of year
max(RAINFALL(10593:10957);
It is exhausting to do it manually and i have quite few of same data sets. Thank You

Answers (1)

Matt J
Matt J on 10 Aug 2014
Edited: Matt J on 10 Aug 2014
v=datevec(datenum([2009 12 31 0 0 0])+(1:10957));
result = accumarray(v(:,1)-2009,RAINFALL,[],@max)
  8 Comments

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!