Help in averaging climate data
1 view (last 30 days)
Show older comments
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 Comments
Kye Taylor
on 6 Jun 2013
So, which columns of the 13 are the four you describe above, and which one is the climate data?
Answers (2)
Roger Stafford
on 6 Jun 2013
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 Comments
Roger Stafford
on 6 Jun 2013
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),:);
See Also
Categories
Find more on Climate Science and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!