Using loop to solve a summation
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Is this correct

m=0
for m=0:1200
x=sum(1/factorial(m))
end
0 commentaires
Réponses (2)
Star Strider
le 7 Fév 2019
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))
0 commentaires
Kevin Phung
le 7 Fév 2019
Modifié(e) : Kevin Phung
le 7 Fév 2019
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 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!