% Predator-Prey System
% Oliver Rheinbach 2010
% Universitaet Duisburg-Essen

% construct grid
x=0:.2:3
y=0:.2:3
[X,Y]=meshgrid(x,y);

% define function
F1=@(X,Y) [X.*(1-Y)];
F2=@(X,Y) [Y.*(X-1)];

U=F1(X,Y);
V=F2(X,Y);

% plot 
fig=figure;
quiver(X,Y,U,V);
xlabel('prey');
ylabel('predator');

% save a copy to disk
saveas(fig,'predatorprey.png','png');

%quiver(X,Y,U,V,'-','filled');
%XY=stream2(U,V,x(end-3:end),y(end-3:end));
%streamline(XY);

% construct grid for contour plot
x=0:.2:3
y=0:.2:3
[X,Y]=meshgrid(x,y);

% contour plot
alpha=1;
g=@(u,v)u+v-log((u.^alpha).*v);
fig=figure
contour(X,Y,g(X,Y));

% save a copy to disk
saveas(fig,'predatorprey2.png','png');

