%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% phase portrait for Lotka-Volterra
%
% mouse click in graphics window: start flow
%
% any button press at any position in window [ESC]: EXIT
%
% VHS Oct. 2003
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clf
[y1,y2]=meshgrid(-10:20:500,-10:20:500);
a=2;b=1;c=0.01;d=0.01;
v1= a*y1 - c*y1.*y2;
v2=-b*y2 + d*y1.*y2;
quiver(y1,y2,v1,v2);
hold on;
k = 0;
while (k == 0)
    k = waitforbuttonpress;
    point = get(gca,'CurrentPoint');
    point = point(1,1:2);              % extract x and y
    [t,y]=ode23('lv',[0 5],point);
    plot(y(:,1),y(:,2),'r-');
end

