Finding the Sum of a Finite Series

33 ビュー (過去 30 日間)
Agnieszka Polak
Agnieszka Polak 2019 年 12 月 6 日
編集済み: Agnieszka Polak 2019 年 12 月 6 日
Hello,
I am trying to calculate the sum of a series. I am trying to use a while loop, however, I keep getting stuck. Any ideas how to proceed?
Thank you

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 6 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 6 日
No need any loop, just check here
Still having trouble, let me know?
  1 件のコメント
Agnieszka Polak
Agnieszka Polak 2019 年 12 月 6 日
Thank you very much!

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

その他の回答 (1 件)

Turlough Hughes
Turlough Hughes 2019 年 12 月 6 日
編集済み: Turlough Hughes 2019 年 12 月 6 日
Here I just use some examples for x,y and n, and also instead of 'i' I used 'c' as 'i' is designated for complex numbers.
c=1; x=3; y=4; n=4;
addends=zeros(n,1)
while c<=n
addends(c)=(x*y)^c
c=c+1;
end
sum(addends)
addends are just the parts that will then be added together after the loop using the sum function.
Alterantively you could also just do this:
x=3; y=4; n=4;
sum((x*y).^[1:n])
  1 件のコメント
Agnieszka Polak
Agnieszka Polak 2019 年 12 月 6 日
Thank you!

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by