data_input=[1;1;1;1;1;1;1]
data_output=[1;2;3;4;5;6;7]
how can i achieve this with a for loop? basically take the preceding value and add it to the next one and then repeat as new values emerge.

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 1 月 15 日
編集済み: Azzi Abdelmalek 2015 年 1 月 15 日

0 投票

a=[1 1 1 1 1]
b=cumsum(a)

1 件のコメント

matlabuser12
matlabuser12 2015 年 1 月 15 日
編集済み: matlabuser12 2015 年 1 月 15 日
for some reason i thought that summed the whole column and never tried it. thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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