Euler's method help
Mostra commenti meno recenti
I am trying to plot an euler's method for dx/dt=-100x for x(t)=x(0)e^(-100t) with x(0)=1.My code is
x = 1;
h = 0.001;
n_final = 5;
n = 0;
while (n < n_final)
x(n+h) = x(n)+h*(-100*x(n));
n = n+h;
end
plot(x(n), n)
why is my code not working? I want to plot the numerical solution xn vs x.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!