Grid data into monthly average?

3 次查看(过去 30 天)
Hello All,
I have a grid data set for 32 years (384 months) in the form A=(180*360*384), I want to find monthly average for the January. that means average for 32 years for January. I tried to reshape the data however, its not working, can somebody help me out here please?
I am trying with this
R=reshape (A,12,32)
However, i am getting error.
Thanks
  2 个评论
dpb
dpb 2014-12-10
What, precisely, is the storage arrangement again? Is it 3D of A(180,364,384) or is it simply a vector of length(180*364*384)? What do the 180 and 364 refer to; 364 seems peculiar if is days instead of 365 or is that a typo?
The key here is where are the values for Jan 1 for year one and subsequent years -- not exactly sure.
Hydro
Hydro 2014-12-10
My apologies its 384. they shows monthly data (32 years in total). while 180 is latitude and 360 is longitude. So all it means the spread for the entire globe (1 degree unit) for the 32 years. I am really struggling with this and would appreciate any help.

请先登录,再进行评论。

采纳的回答

Mohammad Abouali
Mohammad Abouali 2014-12-10
编辑:Mohammad Abouali 2014-12-10
You are on right track:
Use this:
% Making some sample random data
A=rand(180,360,384);
% reshaping
Areshaped=reshape(A,180,360,12,32);
% Averaging along the 4th dimension (year)
Amean=mean(Areshaped,4);
size(Amean)
180 360 12
  2 个评论
Hydro
Hydro 2014-12-10
Assalam-O-Alaikum Mohammad,
Many thanks for the help. So the average would be for every month for 32 years. Now i need to plot the January over the globe (my lat and long data) in the contour form.
Some of the function i am trying is
[lon lat]=Meshgrid(linspace(min(lon),max(lon)),linspace(min(lat),max(lat)));
contourf(lon, lat,Amean(:,4)); % but this would do for the entire 12 months?
Hydro
Hydro 2014-12-10
i guess i am wrong in using meshgrid? I shouldn't use min and max as the data will then be plotted wrongly.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by