채택된 답변

madhan ravi
madhan ravi 2019년 9월 2일
편집: madhan ravi 2019년 9월 2일

0 개 추천

Perhaps you just want cumsum()
help cumsum
doc cumsum
Or you just need:
v= accumarray(n(:),n(:),[],@(x) sum(vectorA(1:x)));
Wanted = v(n);
% or
Wanted = arrayfun(@(x) sum(vectorA(1:x)),n)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2019a

태그

Community Treasure Hunt

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

Start Hunting!

Translated by