MATLAB: How to calculate monthly mean, variance, lag-1 autocorrelation and other statistical properties

statistical properties

I have daily precipitation data from 1975-2005 in one column. I need to find the statistical properties for monthly. How to split the data and just use code mean(data) to find mean? If I use mean(data), it gives only one answer because they sum up everything. But, in my case, I want to find mean every month within the years. Did someone know how to solve this?

Best Answer

The starting point should be reshaping the data in a way such that you will be able to see them as monthly values. For that purpose, you need to use reshape command as follows: (I will name your variables as a and b)
a=reshape(a,31,[]);
b=reshape(b,31,[]);
By these two commands, we now put your data in a order so that you will have 365 months of data, each one having 31 daily data. Then, by using mean command, you will find each month's average. Your two data are now having sizes of 31x365.
Average_a=mean(a);
Average_b=mean(b);
Hope this helps.