loop subsampling a timetable for each year for annual max values
Show older comments
I have 9 different daily-interval timetable datasets, each spanning ~100 years of data. I need to extract the maximum annual 5-day sum of variable values for each year, in each dataset.
I've figured out how I can get the maximum 5-day sum across the entire 100 year dataset:
v = Timetable_1of9.Var1 ;
n = 5 ;
N = length(v) ;
sumn = zeros(1, N - n + 1); % Pre-allocation
for i = 1:N - n + 1
sumn(i) = sum(v(i:(i+n-1))) ;
end
[val,idx] = max(sumn)
but I'm not sure of the most efficient way to do this for each year and each dataset. (I also need those values put back into 9 new timetables with each annual maximum assigned to 1-1-YYYY, to match in with later analysis I will be doing).
If there a way I can set up a batch or a another for loop to run through each? even if it just does 1 dataset at a time, I can easily copy the code 8 more times and change the input file. Doesn't need to be pretty, just needs to work.
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion 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!