Borrar filtros
Borrar filtros

mean seasonal data

4 visualizaciones (últimos 30 días)
niclo
niclo el 23 de Feb. de 2012
Comentada: Robert el 23 de Mayo de 2018
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 comentarios
Oleg Komarov
Oleg Komarov el 23 de Feb. de 2012
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 el 24 de Feb. de 2012
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.

Iniciar sesión para comentar.

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 23 de Feb. de 2012
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

Más respuestas (1)

Danhay
Danhay el 22 de Feb. de 2016
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 comentarios
saida ghrab
saida ghrab el 18 de Mayo de 2017
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 el 23 de Mayo de 2018
Hi Danhay, would be possible to have the latest link to your script? Links provided are not working.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by