dx/dt = r*xdt=0.1; % set the time step
T=50; % set the time duration
Niter = ceil(T/dt); % determine the number of iterations
x = zeros(Niter,1); % preallocate the solution array
x(1)=2000; % set the initial value
t = zeros(Niter,1); % preallocate the time array
r=-0.5; % set the growth rate
So how to plot its analytic solution (x=2000*exp(r*(t – 1)))? Furthermore, how to plot analytic solution given Backward Euler (x(i+1) = x(i)/(1-r*dt);t(i+1) = t(i) + dt)?
Best Answer