Hi, how would I add values in a loop after iteration. eg. say values that came out were 1,2,3,4,5. I would want an array of 1,3,6,10,15. So 3rd number is first 3 added together and 5th is the first 5 etc. Thank you.
iiTerm = zeros(10,1)
for ii = 1:10
iiTerm(ii) = (((-1).^(ii-1)).*(((pi/4).^(2.*(ii-1))))./(factorial(2.*(ii-1))));
end

 採用された回答

Torsten
Torsten 2017 年 10 月 27 日

0 投票

You mean
for ii = 1:10
iiTerm(ii) = (((-1).^(ii-1)).*(((pi/4).^(2.*(ii-1))))./(factorial(2.*(ii-1))));
end
iiSum = cumsum(iiTerm);
?
Best wishes
Torsten.

1 件のコメント

James Crowe
James Crowe 2017 年 10 月 27 日
Thats exactly it! thank you very much!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2017 年 10 月 27 日

コメント済み:

2017 年 10 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by