필터 지우기
필터 지우기

special sum of an array

조회 수: 1 (최근 30일)
Rica
Rica 2015년 6월 30일
답변: Sean de Wolski 2015년 6월 30일
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일
That's a cumulative sum, cumsum is the function you want:
a = [1 2 3]
cumsum(a)
ans =
1 3 6

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by