function fun = perplot ( it, x, y, T, tmax );
% PerPlot
%
% 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 :  Jun 1, 2004
%
% Visualization of intermediate results in the computation of a periodic solution
%
% Reference
%   J.D. Murray: Mathematical Biology I, 3rd ed. - Springer - 2002.
%     Section 3.4
%
% Parameter
%   it     (input)  : iteration counter
%   x      (input)  : independent variable
%   y      (input)  : pointwise given numerical solution
%   T      (input)  : period length
%   tmax   (input)  : defines XLim in state plot
%   fun    ( - )    : dummy
%
% Example
%   perplot ( x, y, y(3,end), 30 );

% -> continuous output
tauint = linspace ( 0, 1, 1001 );
uint   = spline ( x, y(1,:), tauint );
vint   = spline ( x, y(2,:), tauint );
    
% -> phase plot
subplot ( 2, 1, 1 );
plot ( uint, vint, 'b', uint(1), vint(1), '+b', uint(end), vint(end), 'ob' );
axis ( [ 0 0.8 0 0.4 ] );
xlabel ( 'u' );    ylabel ( 'v' );   
title ( sprintf ( 'Iteration step  it = %3i ,  period  T = %8.4f', it, T ) );

% -> state plot
subplot ( 2, 1, 2 );
plot ( T*tauint, uint, 'b', T*tauint, vint, 'g' );
legend ( 'u', 'v' );
axis ( [ 0 tmax 0 0.8 ] );
xlabel ( 't' );
title ( sprintf ( 'Iteration step  it = %3i ,  period  T = %8.4f', it, T ) );

% -> output to file
orient tall
eval ( sprintf ( 'print -dpng ../png/percoll%1i.png', it ) )