How to calculate monthly data from daily rainfall data in a time-seris 3-dimensional matrix?

5 views (last 30 days)
I have a matrix with the size of 17 x 22 x 332. 17 stands for Latitude, 22 Longitude and 322 is days starts from Apr 1st, 2014 to Feb. 26st, 2015. At the end I should have a matrix with the size of 17 x 22 x 11.
I have tried different ways using reshape, permute etc. but I couldn't find the right way.
Since in the fiture I might use data from longer time-period (for example 15 years) I would like to derive aggregated rainfall for each month using datetime or timetable function, if possible.
I would appreciate any help.

Accepted Answer

Walter Roberson
Walter Roberson on 16 Mar 2019
mat2cell() to break the 17 x 22 x 332 up into cell arrays 17 x 22 x number_of_days_in_month . Then you can cellfun(@(M) sum(M,3), the_cell_array, 'uniform', 0) to get a 17 x 22 x 11 cell after which you cell2mat() to get 17 x 22 x 11 array.

More Answers (0)

Categories

Find more on Dates and Time 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!