sum contents of array in groups of 10

1 view (last 30 days)
C.G.
C.G. on 21 Jan 2021
Commented: C.G. on 21 Jan 2021
My code produces a variable 'grains' which is a 1x3001 double.
I want to sum together the numbers in the first 10 cells, and repeat this in blocks of 10 cells until the end and save these in a new variable.
Please could somebody provide me with a starting point?
  2 Comments
C.G.
C.G. on 21 Jan 2021
i dont want to include the last one

Sign in to comment.

Accepted Answer

Stephen
Stephen on 21 Jan 2021
Where V is your 1x3001 vector:
M = sum(reshape(V(1:3000),10,[]),1)

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by