MATLAB: Calculate the accumulation of a variable over time within a loop

fieldmeanloopsummation

Hello,
I have evaporation as daily values (m). I have calculated the weighted fieldmean, which gives me a vector with length = no. of days. However, I would like to display these values as monthly sums.
How can I do this in a loop?
For example:
newsum(1) = nansum(data(1:30)) and so forth…

Best Answer

Once you get the month data, the code will be almost identical to this answer:
Instead of @std, you'll want to pass in @sum