function [t,y]=eulerBasic( yp, tspan, y0, h ) %Get initial and final times: [m n] = size( tspan ); t = tspan(1, 1); tfinal = tspan(m, n); %Initialize the differential equation y = y0(:); tout = t; yout = y.'; while (t < tfinal) if t + h > tfinal, h = tfinal - t; end % Compute the slope s1 = feval(yp, t, y); % Update t = t + h; n = n + 1; y = y + h*s1; tout = [tout; t]; yout = [yout; y.']; end; % while