sum contents of array in groups of 10

3 次查看(过去 30 天)
C.G.
C.G.2021-1-21
评论: C.G. ,2021-1-21
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 个评论
C.G.
C.G. 2021-1-21
i dont want to include the last one

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by