% Usage: y = eulerstep(f,t,x,h) % One step of Euler's method for initial value problems % % Input: % f - Matlab inline function f(t,y) % t - initial time instant % x - initial condition % h - stepsize % % Output: % y - computed solution at t+h % % Examples: % y=eulerstep(@myfunc,0,1,0.1); here 'myfunc' is a user-defined function in M-file % y=eulerstep(inline('sin(y*t)','t','y'),0,1,0.1); % f=inline('sin(y(1))-cos(y(2))','t','y'); % y=eulerstep(f,0,1,0.1); function y = eulerstep(f,t,x,h) y = x + h * f(t,x);