Sum specific intervals of rows for a matrix
Show older comments
Hello everybody,
I know there are some similar posts regarding the topic but I was not able to solve my problem.
I have a matrix a=53320x228 and wanted to calculate the sum in intervals of 12 for each row (f.e. sum of elements 1:12,13:24... for each row), so that my output would be a 53320x19 matrix as each row has 19*12 elements. In the past I was always able to handle similar problems with:
reshape(sum(reshape(...)))
or
sum(reshape())
But unfortunately, this time I did not recognize how it will work. Other topics related to the problem also suggest to use reshape but it doesn't produce the desired results.
Hopefully someone could help me out, I would really appreciate each hint.
Accepted Answer
More Answers (1)
Danielle Torp
on 31 Oct 2018
0 votes
I have a follow up to this problem- If i wanted to calculate sums in intervals of differing lengths because each column has differing number of rows (i.e. column a = 100 rows, column b = 90 rows), but I want to reshape so each column only has 10 rows (which are sums of equal intervals per column).
3 Comments
Timo
on 31 Oct 2018
Danielle Torp
on 1 Nov 2018
Yes, the rest of the column would be blank.
Timo
on 1 Nov 2018
Categories
Find more on Resizing and Reshaping Matrices 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!