How can I sum each 3 columns array?
조회 수: 2(최근 30일)
표시 이전 댓글
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
Thanks!

댓글 수: 0
채택된 답변
추가 답변(1개)
Walter Roberson
2021년 10월 15일
reshape(x, size(x,1), 3, [])
now you can sum along the second dimension, and then reshape to remove the now-singular second dimension.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!