Model of Dog chasing problem

function wd =doga(t,w);
% This function represents the model of the dog chasing problem,
% when the master walks on a straight line,
% in the form required by ODE23 and ODE45.
% The states are:
% w(1),w(2)             position of the dog

velD=10; velM=5;        % velocities of dog and master
[m,n] = size(w);
wd=zeros(m,n);          % make space to answer
xM = velM*t; yM=100;    % pos. of Master
xD = w(1);              yD = w(2);
dx = xM-xD;             dy = yM-yD;
d  = sqrt(dx*dx+dy*dy);
if (d>0),
wd(1) = velD*dx/d;
wd(2) = velD*dy/d;
end; % of if