creating a loop to generate a plot
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I don't quite undertsnad this question could i please get some help?
Create a for loop to generate the first 20 terms of the estimation of e given by
(1+(1/n))^n ≈ 𝑒. Store all the individual estimates in an array called terms. Then plot the terms array to see the value get closer and closer to 2.7183, using a logarithmic y axis, as shown below.
here is what i have so far
clc,clear
x = 0;
for n = 1:20
y = (1 + (1/n).^n);
x = x + y;
end
x1 = 2.7183;
for index = 1:20
y1 = (1 + (1/index).^index);
x1 = y1 - x1;
end
plot(x1,x)
axis([0,20 ,2, 2.8])
0 commentaires
Réponse acceptée
VBBV
le 31 Oct 2020
Modifié(e) : VBBV
le 31 Oct 2020
%if true
% code
%end
n = 1:100;
YY = (1+1./n).^n;
plot(n,YY); figure(2);semilogy(YY,n);
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Scatter Plots 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!