Hi! How can I calculate the average for a 160x140x1x12 which are lat,lon,year and month. I want to calculate the average of month for one year.

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 6 日

1 投票

You can specify the dimension to the mean() function
M = rand(160,140,1,12);
M_new = mean(M, 4)

6 件のコメント

Nurul Ain Basirah Zakaria
Nurul Ain Basirah Zakaria 2020 年 11 月 7 日
hi, can i ask. why when i plot a year, for 12 months, the output for y axis is 0-7 and x-axis is 20-105 but if i calculate the average and then i plot, both x and y axis is 20-140 and 20-160. But, y-axis should be 0-7 because of my latitude.
Ameer Hamza
Ameer Hamza 2020 年 11 月 8 日
編集済み: Ameer Hamza 2020 年 11 月 8 日
How are you plotting the two figures? What is the command? Most probably, you are not passing the X and Y matrix in the second case.
Nurul Ain Basirah Zakaria
Nurul Ain Basirah Zakaria 2020 年 11 月 8 日
The first one i use:
[m,n,p,o]=size(E);
>> for i=1:o
pcolor(lon,lat,E(:,:,:,i));
shading interp
colorbar
drawnow
end
and the size of E is 160 140 1 12. the outcome is like the first figure
but when i average/mean for the months(12);
size of new E is 160 and 140.
so i just pcolor(newfile), and the outcome is like the second figure above.
Ameer Hamza
Ameer Hamza 2020 年 11 月 8 日
編集済み: Ameer Hamza 2020 年 11 月 8 日
You also need to pass lon, lat in the 2nd call to pcolor too
pcolor(lon,lat,newfile)
Nurul Ain Basirah Zakaria
Nurul Ain Basirah Zakaria 2020 年 11 月 8 日
sir, thank you very much. excuse me for my slow brain.
Ameer Hamza
Ameer Hamza 2020 年 11 月 8 日
I am glad to be of help! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePolar Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by