フィルターのクリア

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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by