Using loop to solve a summation

12 次查看(过去 30 天)
Oscar H
Oscar H 2019-2-7
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by