increase value in vector

1 回表示 (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by