mean seasonal data

4 次查看(过去 30 天)
niclo
niclo 2012-2-23
评论: Robert 2018-5-23
Hello,everyone. I have a seasonal data set which is 123 x 21 x 23 double. the data is arrange in this way :1st is dec 1959, second is jan 1960, third is feb 1960,forth is dec 1960, fifth is jan 1961 and until feb 2000. I need to mean the DJF of every year so that i will have only 1 value for each year. At the end, i will want to hv only 1 row which the 1st is mean value of DJF1960, 2nd is mean value of DJF1961. Can anyone help me to solve this problem? Thank you.
if I had to do this manualy it probably look like this:
a(1,:)=mean(mean(unnamed(1:3)));
b(1,:)=mean(mean(unnamed(4:6))); . .
n(1,:)=mean(mean(unnamed(120:123)));
all=[a;b;c.....n];
But Of cousre I cannot do it manually because it will probably take the rest of my life! and i have many other set of data. So how can I replicate this for a huge dataset? Can anyone teach me how to write a loop so that i don't have to repeat my work until 123 times?
  2 个评论
Oleg Komarov
Oleg Komarov 2012-2-23
It's not clear how your data is organized.
row 1-3 = data for Dec 1960 - Feb 1961 and so on
What's in column 1,2 etc
And why fo you have 23 layers (3rd dimension)?
niclo
niclo 2012-2-24
My data is arranged in this way:
dec 1959
jan 1960
feb 1960
mar 1960
apr 1960
may 1960
jun 1960
jul 1960
aug 1960
sep 1960
oct 1960
nov 1960
dec 1960
jan 1961
.
.nov 2000
So i would like to extract the DJF for every year, so that my data will become like this:
dec 1959
jan 1960
feb 1960
dec 1960
jan 1961
feb 1961
..
After that, i need to mean the DJF for every year. So at the end my data will become 1 x 41 (because i have 41 years).
My original data is 123 x 21 x 23, the 21 is latitude and 23 is longitude.

请先登录,再进行评论。

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2012-2-23
QD:
idxDJF = sort([[1:12:123],[2:12:123],[3:12:123]]);
Wacc = cumsum(unnamed(idxDJF,:,:));
Wavg = Wacc(3:3:end,:,:)/3;
Will leave you with a Wavg with size: 11 x 21 x 23.
HTH

更多回答(1 个)

Danhay
Danhay 2016-2-22
I am answering this in case someone else is having a similar problem. I have a matlab script to handle this problem for both 2D and 3D data: http://dans7messiah.thoughts.com/posts/calculating-the-mean-for-a-selected-period-to-create-a-time-series-of-mean-matlab
Cheers, Daniel
  3 个评论
saida ghrab
saida ghrab 2017-5-18
Hello Danhay, I have the same problem but I couldn't download the script can you please check the link. Thank you so much
Robert
Robert 2018-5-23
Hi Danhay, would be possible to have the latest link to your script? Links provided are not working.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by