Euler's method help
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!