function func = quivdemo ( nu, nv, maxlen );
% QuivDemo
%
% This m-file is part of the material of the lecture
%   Scientific Computing and Software Tools
% at the Math Department of Halle University, Germany.
% Summer term 2004
%
% Author :      Prof. Dr. M. Arnold, arnold@mathematik.uni-halle.de
% Version of :  Apr 6, 2004
%
% Demonstration of Matlab command quiver, Example 1.2
%
% Parameters
%   nu     (input)  : number of mesh points, u-direction
%   nv     (input)  : number of mesh points, v-direction
%   maxlen (input)  : upper bound for printing arrows, maxlen=0 indicates no bound
%
% Example
%   figure ( 1 );   quivdemo ( 17, 25,   0 );
%   figure ( 2 );   quivdemo ( 17, 25, 200 );

% -> problem parameters Lotka-Volterra, see lotkademo.m
alpha = 0.01;
beta  = 0.02;

umin = 0;
umax = 160;
vmin = 0;
vmax = 320;

% -> generate mesh data
u = linspace ( umin, umax, nu );
v = linspace ( vmin, vmax, nv );

[ U, V ] = meshgrid ( u, v );

% -> generate derivative data
UP = ( 1 - alpha*V ) .* U;
VP = ( beta*U  - 1 ) .* V;

if maxlen>0,
    len = sqrt ( UP.^2 + VP.^2 );
    UP(len>maxlen) = NaN;
    VP(len>maxlen) = NaN;
end;    

% -> plot
quiver ( U, V, UP, VP, 4 );
axis ( [ umin umax vmin vmax ] );
title ( 'Lotka-Volterra  \alpha = 0.01,  \beta = 0.02'  );
xlabel ( 'u' );   ylabel ( 'v' );
set ( gca, 'DataAspectRatio', [ 1 1 1 ] );




