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

2 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 4 Aug 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 Comments
Aarti Soni
Aarti Soni on 5 Jul 2023
Edited: Aarti Soni on 5 Jul 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!