% AdBash2Driver.m % This is a driver that inputs the appropriate % initial conditions and step size for using the % function AdBash2.m to solve the IVP given by % y' = f(t,y) y(t0)=y0 % using a Two-Step Adams-Bashforth Method. % Note that this driver inputs the function f.m % to obtain function values for f(t,y) % Note that it uses an Modified-Euler startup. % Clear Workspace clear % Set initial conditions t0 = Edit; y0 = Edit; name ='UserMustEDITThis' %string containing %the name of the function %to be evaluated. % Set step size and number of steps taken in the % multistep algorithm h = Edit; M = Edit; %------------ One-step Startup Here -----------% % Apply Modified-Euler.m for 1 startup step [t,y]=ModEul(name,h,1,t0,y0); %-----------------------------------------------% %-------- Two-step Adams-Bashforth Here --------% % Apply AdBash2.m function [t_vec,y_vec]=AdBash2(name,h,M,t,y) %-----------------------------------------------% % t_vec is the vector of t-values from the step % size given by h. % y_vec is the corresponding approximations for the % solution to the IVP. We can plot the linear interpolant % of the approx. solution values along with the true solution % to compare. %-------- Construct True Solution Values --------% t2 = [t0:0.1*h:t0+(M+1)*h]; %TrueSoln_vec = You put stuff here; %------------------------------------------------% %-------------------- Plots ---------------------% figure(1) plot(t_vec,y_vec,'g--',t2,TrueSoln_vec,'r-',t_vec,y_vec,'g*'); legend('Two-Step Adams-Bashforth','True Solution'); xlabel('t'); ylabel('y(t)'); %------------------------------------------------%