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;endplot(x(n), n)
why is my code not working? I want to plot the numerical solution xn vs x.
Best Answer