function E=eulers(f,a,b,ya,h) %Input - y'=f is the function % - a and b are the left and right endpoints % - ya is the initial condition y(a) % - h is the step size %Output - E=[T' Y'] where T is the vector of abscissas and % - Y is the vector of ordinates % NUMERICAL METHODS: Matlab Programs % (c) 2007 by Xie Liling % Complementary Software to accompany the textbook: % Information and Computing Science: A Laboratory Course M=ceil((b-a)/h); T=zeros(1,M+1); Y=zeros(1,M+1); T=a:h:b; Y(1)=ya; for j=1:M Y(j+1)=Y(j)+h*feval(f,T(j),Y(j)); end E=[T' Y'];