How can I sum each 3 columns array?

4 views (last 30 days)
ang bn
ang bn on 14 Oct 2021
Answered: Walter Roberson on 15 Oct 2021
Hi, i want to sum each 3 columns of my array for any array dimension.
For example, Y array is the sum of each X array respectively to its color.
Need this to do sum for Nx150 array, so that it can turn into Nx50 array

Accepted Answer

David Hill
David Hill on 14 Oct 2021
ang bn
ang bn on 14 Oct 2021
okay now I'll just do matlab online, maybe later I will install newer version

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 15 Oct 2021
reshape(x, size(x,1), 3, [])
now you can sum along the second dimension, and then reshape to remove the now-singular second dimension.




Community Treasure Hunt

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

Start Hunting!