sum of elements of an array
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm sorry for the stupid question, but If i have an array A = [1,2,5,7,9] and i want an array B = [1,3,8,15,24], progressive sum of the elemts in A, what is the code that returns me B? Thanks!
0 comentarios
Respuestas (1)
John D'Errico
el 26 de Feb. de 2021
Editada: John D'Errico
el 26 de Feb. de 2021
B = cumsum(A);
You could have learned about this function by reading the help for sum. At the bottom of the help, you would see a see also line. That reads:
See also prod, cumsum, diff, accumarray, isfloat.
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!