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!

 채택된 답변

Sean de Wolski
Sean de Wolski 2015년 6월 30일

1 개 추천

That's a cumulative sum, cumsum is the function you want:
a = [1 2 3]
cumsum(a)
ans =
1 3 6

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Types에 대해 자세히 알아보기

태그

질문:

2015년 6월 30일

답변:

2015년 6월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by