% main1a.m
y0 = [0 10]';
options= odeset('AbsTol',1e-8);
[t y] = ode45 ('f1a', [0 30], y0, options);
[X, Xs, Y, Ys] = child1a (t);

xmin = min (min (X), min (y (:, 1)));
xmax = max (max (X), max (y (:, 1)));
ymin = min (min (Y), min (y (:, 2)));
ymax = max (max (Y), max (y (:, 2)));

clf; hold on;
axis ([xmin xmax ymin ymax]);
%axis('equal')
title ('The Child and the Toy.');
stickhandle = line ('Color', 'yellow', 'EraseMode', 'xor', ...
                    'LineStyle', '-', 'XData', [], 'YData', []);

for k = 1:length(t)-1,
   plot ([X(k), X(k+1)], [Y(k), Y(k+1)], '-', ...
         'Color', 'yellow', 'EraseMode', 'none');
   plot ([y(k,1), y(k+1,1)], [y(k,2), y(k+1,2)], '-', ...
         'Color', 'green', 'EraseMode', 'none');
   set (stickhandle, 'XData', [X(k+1), y(k+1,1)], ...
        'YData', [Y(k+1), y(k+1,2)]);
   drawnow;
   %pause(1);
end;
hold off;
