MATLAB: Average of 3d matrix

3d matrixaverage

hi
I have 3D matrix with dimension (61,57,365) the 365 is daily time. I want to do a monthly average overtime to get (61,57,12). But the number of days each month is different. I would be grateful for your help

Best Answer

#One Way
m=cumsum([0,31,28,31,30,31,30,31,31,30,31,30,31]);
data=rand(61,57,365); %Sample Data
month_ave=zeros(1,12)
for i=1:12
data1=data(:,:,m(i)+1:m(i+1));
month_ave(i)=mean(data(:));
end
month_ave