increase value in vector

조회 수: 3 (최근 30일)
Lev Mihailov
Lev Mihailov 2020년 2월 3일
답변: David Hill 2020년 2월 3일
X=[102 103 116 145 108] %
iwant=[102 205 321 466 574] % what i need to get
% 102+103=205 ; 205+116=321 ;
for i=1:length(n)-1 % I tried to make such an option, but it does not work
X1(i)=X(i)+X(i+1)
end
Help, how can I do this better?

채택된 답변

David Hill
David Hill 2020년 2월 3일
X1=cumsum(X);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by