MATLAB Answers

0

how to sum first 140 elements every time in an (1 * 21000) array

Asked by pavan kumar on 19 Nov 2019 at 11:54
Latest activity Commented on by pavan kumar on 19 Nov 2019 at 15:27
a=rand(1,21000);
how to add (1 to 140,141 to 280, 281 to 420........elements up to 20861 to 21000. and totally i have 21000/140=150 i.e (1row * 150 columns)
and store it in same 'a'

  0 Comments

Sign in to comment.

2 Answers

Answer by David Hill on 19 Nov 2019 at 11:58
 Accepted Answer

b=sum(reshape(a,[140,150]));

  1 Comment

Sign in to comment.


Answer by JESUS DAVID ARIZA ROYETH on 19 Nov 2019 at 11:56

solution:
a=rand(1,21000);
b=sum(reshape(a,140,[]));

  1 Comment

Sign in to comment.