special sum of an array

2 visualizaciones (últimos 30 días)
Rica
Rica el 30 de Jun. de 2015
Respondida: Sean de Wolski el 30 de Jun. de 2015
hi all, is there any function to do this simply:
Array=[a1 a2 .......an]
i want to calculate this:
ArraySum=[a1 a1+a2 a1+a2+a3 .......a1+a2+a3+...an]
Thank you!

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 30 de Jun. de 2015
That's a cumulative sum, cumsum is the function you want:
a = [1 2 3]
cumsum(a)
ans =
1 3 6

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by