How can I sum each 3 columns array?

4 visualizaciones (últimos 30 días)
ang bn
ang bn el 14 de Oct. de 2021
Respondida: Walter Roberson el 15 de Oct. de 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
Thanks!

Respuesta aceptada

David Hill
David Hill el 14 de Oct. de 2021
m=movsum(x,3);
y=m(:,1:3:end);
  3 comentarios
Walter Roberson
Walter Roberson el 14 de Oct. de 2021
movsum is R2016a and newer
ang bn
ang bn el 14 de Oct. de 2021
okay now I'll just do matlab online, maybe later I will install newer version
thanks!

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 15 de Oct. de 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.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by