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

2 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2022-8-4
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 个评论
Aarti Soni
Aarti Soni 2023-7-5
编辑:Aarti Soni 2023-7-5
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by