%  This function solves homework problem [H1.4]
%  --------------------------------------------
%
diary nsds_hw1_4.dry
echo on
%
x0 = [ 0.1 , 0.1 ];
options = odeset('reltol',1e-9);
%
%  First part: trev = 2.0
%
tf = 4;
trev = 2;
[t,x] = ode45(@nsds_hw1_4m,[0,tf],x0,options,trev);
[n,m] = size(x);
xf = x(n,:);
err = norm(xf - x0)
subplot(2,1,1)
plot(t,x(:,1))
grid on
title('Homework [H1.4]')
xlabel('time')
ylabel('x')
%
%  Second part: trev = 20.0
%
tf = 40;
trev = 20;
[t,x] = ode45(@nsds_hw1_4m,[0,tf],x0,options,trev);
[n,m] = size(x);
xf = x(n,:);
err = norm(xf - x0)
subplot(2,1,2)
plot(t,x(:,1))
grid on
xlabel('time')
ylabel('x')
%
print -deps nsds_hw1_4.eps
diary off
return


