function [t,y]=euler(a,b,h,y0) %function [t,y]=euler(a,b,h,y0) %Solution using Euler's Method. Determines a solution y(t) % for t=a to t=b using step size h and initial condition y0. % To change the differential equation, go to the second to % last line- In the command window, type: edit euler.m t=a:h:b; n=length(t); y=zeros(n,1); y(1)=y0; for i=2:n y(i)=y(i-1)+h*f(t(i-1),y(i-1)); end %********************************* function dy=f(t,y) dy=1-t+4*y; return