% Chapter 14 Exercise 4b.
r=15; velD=2.5; velM=2; % parameters
w0=[0;0]; % initial conditions
t0=0; tf=10; % initial and final time
% --- run simulation
[t,w]=ode23('dogb',t0,tf,w0);
% --- build xD, yD, position of the dog
xD=w(:,1); yD=w(:,2);
% --- build xM, yM, position of the master
al=velM/r*t;
xM= r*cos(al); yM= r*sin(al);
be=linspace(0,2*pi);
% --- build XB, yB, the bank
xB=r*cos(be); yB=r*sin(be);
% --- plot
plot(xB,yB, xD,yD,'+',xM,yM,'o');
axis([-r r -r r]);
axis('equal');
title('Dog chasing his master');
grid