sum of elements of an array
조회 수: 6 (최근 30일)
이전 댓글 표시
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
답변 (1개)
John D'Errico
2021년 2월 26일
편집: John D'Errico
2021년 2월 26일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!