Você está na página 1de 1

Matlab Code for Euler Method

function E=euler(f,a,b,ya,M)
%Input - f is the function entered as a string 'f'
% - a and b are the left and right endpoints
% - ya is the initial condition y(a)
% - M is the number of steps
%Output - E=[' !'" #here is the $ector of abscissas and
% ! is the $ector of ordinates
h=(b-a)%M&
='eros(()M*()&
!='eros(()M*()&
=a+h+b&
!(()=ya&
for ,=(+M
!(,*()=!(,)*h-fe$al(f)(,))!(,))&
end
E=[' !'"&
!!=euler(f)a)b)ya)M)
plot(yy(+)()) yy(+).))

Você também pode gostar