How can I sum each 3 columns array?
Mostra commenti meno recenti
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!

Risposta accettata
Più risposte (1)
Walter Roberson
il 15 Ott 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.
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!