increase value in vector

1 Ansicht (letzte 30 Tage)
Lev Mihailov
Lev Mihailov am 3 Feb. 2020
Beantwortet: David Hill am 3 Feb. 2020
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?

Akzeptierte Antwort

David Hill
David Hill am 3 Feb. 2020
X1=cumsum(X);

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by