Sum for every n number within a single column vector
Show older comments
I have a Precipitation vector 35090x1, which represents measurements taken every 30 minutes (48 measurements a day) over the course of 2 years. I would like to calculate daily totals for these two years by summing each of the 48 measurements taken each day. How do I do this?
Accepted Answer
More Answers (1)
The inside-information way is just
sum(reshape(x,48,[]))
making use of internal storage order and that Matlab functions operate column-wise by default. This does mean you have to know such details about data storage.
The higher-level route to more legible coding is as pointed to in the comment above or similar utilizing the special time-based functionality builtin to later releases.
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!