function main
x0 = 0.0;
x1 = 1.5;
fun = @(x,y) y-x;
h = [0.25 0.05 0.01];
for i = 1:numel(h)
[x{i},y{i}] = euler(fun,x0,x1,h(i));
end
plot(x{1},y{1},x{2},y{2},x{3},y{3})
end
function [x,y] = euler(fun,x0,x1,h)
x(1) = x0;
y(1) = 2.0/3.0;
N = (x1-x0)/h;
for i=2:N+1
y(i) = y(i-1) + h*fun(x(i-1),y(i-1));
x(i) = x(i-1) + h;
end
end
