I am interested in calculating GPH anomalies in Matlab. I have a 3D matrix of lat, lon, and time. Where time is a daily GPH value for 32 years (1979-2010). The matrix is 95x38x11689. How do I compute a daily average across all years for each day of data, when the matrix is 3D?
I am ultimately trying to compute the GPH anomaly from the difference of the daily value and the climatological mean of that given day.
In other words, how do I compute the average of Jan. 1st dates for all years to compute the climatological mean of all Jan. 1st's from 1979-2010? And so forth for each day after. The data also includes leap years. How do I handle that?
Thanks!
UPDATE: The 3rd dimension is the GPH data NOT time. It's just the data for every day time step from 1979 to 2011.
Try something like this:
An example of getting another arbitrary date say every March 15th. Note that I only changed the first call to
datenum
and not the second.I am assuming that along the 3rd dimension index 1 is Jan 1 1979 & progresses at 1 index per day.
EDIT to get every day This will return a
dailyMeanGPH
that is95x38x366
. Such that dailyMeanGPH(:,:,1) is the mean for every Jan 1st, dailyMeanGPH(:,:,2) = Jan 2nd ... Note that for Feb 29th there will be less days averaged since it will occur 1/4th as often.Alternative you if comment/uncomment the lines noted in the code below your output can be returned in a cell array. That way if you wanted Jan 1 mean you would do
dailyMeanGPH{1,1}
then Jan 2nddailyMeanGPH{1,2}
etc. Where the index into the cell is{month,day}
of interest.