Add value in column to previous?

2 次查看(过去 30 天)
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by