add result to next entry of the column

2 ビュー (過去 30 日間)
aditi
aditi 2014 年 4 月 9 日
コメント済み: aditi 2014 年 4 月 9 日
I have a column as:
1
2
3
4
5
and so on....
I have to add a no. 25 to first enrty and then add the result to next entry...then this result to the 3rd entry...and so on...i.e in above case
25 + 1= 26
26 + 2 = 28
28 + 3 = 31
31+ 4 = 35
and so on...
plz help me....

採用された回答

Chandrasekhar
Chandrasekhar 2014 年 4 月 9 日
編集済み: Chandrasekhar 2014 年 4 月 9 日
if a is your initial array then
sum = 25;
for i = 1:length(a)
sum = sum+a(i);
end
  1 件のコメント
aditi
aditi 2014 年 4 月 9 日
thanks a lot akshata.... :)

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 9 日
out=25+cumsum(1:6)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by