% hw3plot.m % Generates three plots on page: slope field, one symbolic solution, % one numerical solution. Requires the M-files INIT.M, SLOPEF.M, HWSOL1.M. % INIT.M must be called first and contain appropriate entries for all % variables/parameters. figans=input('Do you already have a separate figure window for hw3plot? (y/n) ','s'); if figans=='n'; hwfig=figure; end figure(hwfig) clf subplot(2,2,2) axis(initax) slopef(ftx,N); xlabel(['Slopefield: x'' = ',ftx]) hold off subplot(2,2,3) axis(initax) slopef(ftx,N); ftxslnplot=[]; ttemp=t; t=[]; for j=1:length(ttemp) t=ttemp(j); ftxslnplot=[ftxslnplot,eval(ftxsln)]; end t=ttemp; plot(t,ftxslnplot) xlabel(['Symbolic soln: x = ',ftxsln,', C = ',num2str(C)]) hold off subplot(2,2,4) axis(initax) slopef(ftx,N); hwsol1 xlabel(['Numerical soln: t0 = ',num2str(t0),', x0 = ',num2str(x0)]) hold off figure(hwfig)