how to take mean of three dimension data at seasonal scale?

1 vue (au cours des 30 derniers jours)
Aarti Soni
Aarti Soni le 4 Août 2022
Modifié(e) : Aarti Soni le 5 Juil 2023
Hello everyone,
I have temperature data in matrix (180X360X120). 180X360 respresents latitude and longitude, and 120 represents temperarture in 10 years (120months). I want to take mean of temperature at seasonal scale (MAM, JJA & SON).
Final output should be MAM = 180X360X30; JJA = 180X360X30; SON = 180X360X30
% I have tried the same with vector data
mam = sort([[3:12:120],[4:12:120],[5:12:120]]);
x = reshape(mam,3,numel(mam)/3);
MAM =(data(:,x));
y = reshape(MAM,3,numel(MAM)/3);
temp_MAM = mean(y);
How can I do the same with matrix data?
Thanks

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Août 2022
Same basic way,
mam = reshape([3:12:120; 4:12:120; 5:12:120], 1, []);
MAM = data(:,:,mam);
MAM3 = reshape(MAM, size(data,1), size(data,2), 3, []);
MAM3mean = reshape(mean(MAM3, 3), size(data,1), size(data,2), []);
  2 commentaires
Aarti Soni
Aarti Soni le 4 Août 2022
Thanks @Walter Roberson for help.
Aarti Soni
Aarti Soni le 5 Juil 2023
Modifié(e) : Aarti Soni le 5 Juil 2023
Similarly, I have 15days temperature data for 10 years means every month is having two files and data is in three dimension format (i.e., 180 X 360 X 240). I want to take mean of every two files to make it monthly mean (180 X 360 X 120).
How can I do this with reshape function or is there any other way to solve this?
I always appreciate for your help.
Thanks in advance.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by