Borrar filtros
Borrar filtros

Averaging time series for a season

3 visualizaciones (últimos 30 días)
HA
HA el 14 de Jul. de 2020
Respondida: Jaynik el 16 de Jul. de 2024 a las 5:54
Hello,
I have a 3d time series with month as the last dimension (latxlonxmonth) with 300 years worth of data, I have been using the annual average function for annual time series (latxlonx300)-
A = squeeze(nanmean(reshape(B,[s(1:2),12,s(3)/12]),3));
I now need to do a similar time seires but just for a specific season -June, July, August (latxlonx300).
How would I go about taking a seasonal mean instead of full annual mean? It is probably something simple that my mind is just not getting right now.
Thank you.

Respuestas (1)

Jaynik
Jaynik el 16 de Jul. de 2024 a las 5:54
Hi,
You can follow a similar approach to the one you used for the annual mean. Instead of averaging over all 12 months, you will only average over the months of interest. Following is a general approach:
  1. Reshape the array to separate the years and months.
  2. Extract the months of interest (June, July, August).
  3. Compute the mean over these months.
Here is the MATLAB code:
% Assuming B is your original 3D array (lat x lon x month)
% Reshape the array to separate years and months
B_reshaped = reshape(B, [s(1), s(2), 12, s(3)/12]);
% Extract the months of interest (June, July, August) i.e., 6:8
JJA_months = B_reshaped(:,:,6:8,:);
% Compute the mean over the months of interest
JJA_mean = squeeze(nanmean(JJA_months, 3));
Hope this helps!

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by