Using loop to solve a summation

13 ビュー (過去 30 日間)
Oscar H
Oscar H 2019 年 2 月 7 日
コメント済み: Ishmael Asad 2021 年 4 月 23 日
Is this correct
m=0
for m=0:1200
x=sum(1/factorial(m))
end

回答 (2 件)

Star Strider
Star Strider 2019 年 2 月 7 日
No, because you need to subscript ‘m’ and sum ‘x’ in each iteration.
However you do not need the loop:
m=0:1200;
x=sum(1./factorial(m))

Kevin Phung
Kevin Phung 2019 年 2 月 7 日
編集済み: Kevin Phung 2019 年 2 月 7 日
No, you need to increment m with each step and add each partial sum.
This is what you need:
x= 0
for m = 0:1200
x = x + 1/factorial(m(i))
end
  2 件のコメント
Colby Jennings
Colby Jennings 2021 年 4 月 15 日
why x if there is no x in the equation
Ishmael Asad
Ishmael Asad 2021 年 4 月 23 日
x is just the variable that will store that whole summation

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

カテゴリ

Help Center および 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