Hello ,
I noticed you're seeking assistance with calculating the seasonal mean of your data.
For that you can refer to this sample code which will guide you.
Since I couldn't access the link provided , created some sample data to work with.
rows = 231;
cols = 141;
% Total days for 71 years, assuming 91 days for non-leap years and 92 for leap years
% Leap years add an extra day: 18 leap years in the range 1950-2020
totalDays = (71 - 18) * 91 + 18 * 92;
data = rand(rows, cols, totalDays);
Create an array to store the seasonal mean results with dimensions 231x141x71.
seasonalMean = zeros(231, 141, 71);
Now, Calculate the mean for the specific months for each year, considering leap years.
startIndex = 1;
for year = 1:71
% Check for leap year
if mod(1950 + year - 1, 4) == 0 && (mod(1950 + year - 1, 100) ~= 0 || mod(1950 + year - 1, 400) == 0)
daysInMonths = 31 + 29 + 31; % Adjust for leap year
else
daysInMonths = 31 + 28 + 31; % Non-leap year
end
endIndex = startIndex + daysInMonths - 1;
% Calculate the seasonal mean for the current year
seasonalMean(:,:,year) = mean(data(:,:,startIndex:endIndex), 3);
% Update the startIndex for the next year
startIndex = endIndex + 1;
end
You can also refer to the following MathWorks documentation to learn more about 'mean' and 'mod':
I hope this information helps you move forward with your task!