-2

I have a 189 x 4914 matrix and am trying to find the sum of each row in each 1x26 sub-matrix. How would I go about this?

Many thanks.

1 Answers1

0

Try this:

n = 26;
result = reshape(sum(reshape(x.', n, []), 1), [], size(x, 1)).';

You can look at intermediate results to see how this works: reshape(x.', n, []), then sum(reshape(x.', n, []), 1) etc

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147