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

1 回表示 (過去 30 日間)
Aarti Soni
Aarti Soni 2022 年 8 月 4 日
編集済み: Aarti Soni 2023 年 7 月 5 日
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 2022 年 8 月 4 日
Thanks @Walter Roberson for help.
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 Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by