How can I sum each 3 columns array?
显示 更早的评论
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!

采纳的回答
更多回答(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.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!