필터 지우기
필터 지우기

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