Summation with FOR loop question
Afficher commentaires plus anciens
I am fairly new to MATLAB. How do you get an answer for this using a FOR loop?

Réponse acceptée
Plus de réponses (2)
Geoff Hayes
le 14 Fév 2019
2 votes
Oliver - since this is most likely homework and I'm assuming that you have been instructed to use a for loop, see for loop to repeat specified number of times and factorial. An alternative to using a loop is vecorization..see using vectorization for more details.
format long
fak = 1.0;
s = fak;
for i = 1:1600
fak = fak/i;
s = s + fak;
end
s
exp(1)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!