% Lab 6 Euler's method for solving 1st order ode
tic
clear all; clc;
y=1;
t0=0;
h=0.01;
n=1;
for t=t0:h:5
    f=2-exp(-4*t)-2*y;
    s(n)=y;
    % Euler approx (tangent line)
    y=y+h*f;
    n=n+1;
end
t=t0:h:5;
plot(t,s,'--'); hold on
t=0:0.1:5;
plot(t,1+(0.5)*exp(-4*t)-(0.5)*exp(-2*t));
grid on;
toc