Help in averaging climate data

I am a novice in matlab and looking for help with calculating average monthly data from hourly data.
I have the data for full year in one file and have multiple txt files for different years. Column 1 is year, column 2 is month of year (1 to 12), column 3 is day of month and column 4 is hour of day (0 to 23). Looking forward to some guidance on how to do this.
Thanks in advance

5 件のコメント

Kye Taylor
Kye Taylor 2013 年 6 月 6 日
Have you imported the data into MATLAB? I.e. do you have the data stored in a N-by-4 dimensional matrix yet?
Kye Taylor
Kye Taylor 2013 年 6 月 6 日
So, does a row of the data looks like
[1990, 2, 28, 23] % for 11pm Feb 28 1990
Where is the climate data? Is that stored in another column? or a separate vector?
Sam
Sam 2013 年 6 月 6 日
This is how I imported the data to matlab:
D = importdata('metdata1.txt')
D =
data: [8760x13 double]
textdata: {8760x1 cell}
rowheaders: {8760x1 cell}
Kye Taylor
Kye Taylor 2013 年 6 月 6 日
So, which columns of the 13 are the four you describe above, and which one is the climate data?
Sam
Sam 2013 年 6 月 6 日
And this is what the first row looks like if I am doing it right:
D.data(1,:)
ans =
1.0e+03 *
Columns 1 through 12
1.9730 0.0010 0.0010 0 -0.9990 -0.0999 -0.0090 -0.9999 -0.9999 -0.9999 -0.9999 -0.0990
Column 13
-0.0990

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

回答 (2 件)

Sam
Sam 2013 年 6 月 6 日

0 投票

Yes, I have imported them into matlab
Roger Stafford
Roger Stafford 2013 年 6 月 6 日

0 投票

I'll suppose you have the climate data in column five of an array, A, with the year, month, day, and hour in its columns 1, 2, 3, and 4, respectively.
[u,~,ix] = unique(A(:,1:2),'rows');
B = [u,accumarray(ix,A(:,5))./accumarray(ix,1)];

5 件のコメント

Sam
Sam 2013 年 6 月 6 日
編集済み: Sam 2013 年 6 月 6 日
Hi Roger, Thanks, this seems to produce a matrix for the 12 months. But how not to take into account the "999.9" data i.e. the missing value data in the column?
Roger Stafford
Roger Stafford 2013 年 6 月 6 日
It should produce a row for every year-month combination, not just for 12 months.
If you can fully(!) describe the "missing value" situation, perhaps a solution could be found. As things stand, I can only guess at what you mean.
Sam
Sam 2013 年 6 月 6 日
Actually data for different years are in different files in the data column, a data value of "999.9" means a missing value so not to be considered in the a calculation. Now it is averaging over the entire column for unique values of month.
Roger Stafford
Roger Stafford 2013 年 6 月 6 日
You could initially remove all rows with the "999.9" data values:
A = A(A(:,5)~=999.9,:);
However, it might be better to allow some tolerance for rounding differences:
A = A(abs(A(:,5)-999.9)<100*eps(999.9),:);
Noor Mohd Safar
Noor Mohd Safar 2015 年 7 月 14 日
Thank you guys.

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

カテゴリ

ヘルプ センター および File ExchangeClimate Science and Analysis についてさらに検索

タグ

質問済み:

Sam
2013 年 6 月 6 日

コメント済み:

2015 年 7 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by