You are on page 1of 1

%n numero de intervalos

function [x,y]=eulerp(f,xi,yi,xf,n)
f=inline(f,'x','y');
h=(xf-xi)/n;x=xi;y=yi;
for i=1:n
yi=yi+h*f(xi,yi);
xi=xi+h;
x=[x xi];
y=[y yi];
end

%n numero de intervalos
function [x,y]=eulerr(f,xi,yi,xf,n)
f=inline(f,'x','y');
h=(xf-xi)/n;x=xi;y=yi;
for i=1:n
yis=yi+h*f(xi,yi);
xi=xi+h;
yi=yi+h*f(xi,yis);
x=[x xi];
y=[y yi];
end

You might also like