function func = ploteig ( n );
% PlotEig
%
% This m-file is part of the material of the lecture
%   Theory and Numerics of Partial Differential Equations
% at the Math Department of Halle University, Germany.
%
% Author :      Prof. Dr. M. Arnold, arnold@mathematik.uni-halle.de
% Version of :  Apr 22, 2005
%
% Animated Plot of the solution of Eigenfunctions of a finite string
%
% Parameters:
%   n      (input)  : number of the eigenfunction
%
% Example:
%   ploteig ( 3 );

graphwidth  = 16.0;
graphheight = 12.0;
fac         =  0.95;
shift       =  0.5;
papershift  =  0.0;

ActFontSize   = 14;
ActLineWidth  =  2;
ActMarkerSize = 10;
RatioFlag     =  0;

border      = 1.0;

%
% -> Bestimme Groesse des Bildschirms und Skalierungsfaktor fuer die Ausgabe
root = 0;
set ( root, 'Units', 'centimeters' );
screensize = get ( root, 'ScreenSize' );
left   = screensize(1);
bottom = screensize(2);
width  = screensize(3);
height = screensize(4);
set ( root, 'Units', 'pixels' );
if RatioFlag==0,
  screenscale = 1.0;
elseif RatioFlag==1,
  screenscale = (width-2*border) / graphwidth;
end;

%
% -> Definiere den Bildschirmausschnitt
if length ( get ( root, 'Children' ) ) == 0,
  h = figure;
else
  h = gcf;
  clf;
end;
set ( h, 'Units',    'centimeters' );
set ( h, 'Position', ...
  [ left+width-screenscale*graphwidth-border height-2*border-screenscale*graphheight ...
    screenscale*graphwidth                   screenscale*graphheight ] );
set ( h, 'Units',    'pixels' );

%
% -> Skalierung der Ausgabe in PostScript
%
set ( gcf, 'PaperUnits',    'centimeters' );
set ( gcf, 'PaperPosition', [ papershift papershift graphwidth graphheight ] );

% -> data grid
nx = 201;
nt = 10001;

xmin =  0.0;
xmax =  1.0;
tmin =  0.0;
tmax = 10.0;

x = linspace ( xmin, xmax, nx );
t = linspace ( tmin, tmax, nt );

% -> solution of wave equation
u = sin ( n*pi*x );

% -> first plot
myplot = plot ( x, u, 'LineWidth', ActLineWidth );
xlabel ( 'x' );
ylabel ( 'u' );
title ( 'Bemerkung 2.7: Eigenschwingungen der endlichen Saite' );

hold on;
plot ( [ xmin xmax ], [ 0 0 ], ':k' );
plot ( (0:n)/n, zeros(n+1,1), '*r', 'MarkerSize', ActMarkerSize );
hold off;

axis ( [ 0 1 -1.2 1.2 ] );

drawnow;

%
% -> Korrektur der Groesse und Lage der Koordinatensysteme
allax = get ( gcf, 'Children' )';
for ax = allax,
  rect    = get ( ax, 'Position' );
  rect(2) = rect(2) + shift * (1-fac) * rect(4);
  rect(4) = fac * rect(4);
  set ( ax, 'Position', rect );
end;

%
% -> Aenderung der Schriftgroesse
for hf = allax,
  set ( hf, 'FontSize', [ActFontSize] );
  set ( get ( hf, 'title' ), 'FontSize', [ActFontSize] );
  set ( get ( hf, 'xlabel' ), 'FontSize', [ActFontSize] );
  set ( get ( hf, 'ylabel' ), 'FontSize', [ActFontSize] );
  set ( get ( hf, 'zlabel' ), 'FontSize', [ActFontSize] );
end;

% -> animation
for it=1:nt,
    uact = u*cos(n*pi*t(it));
    set ( myplot, 'YData', uact );
    drawnow;
end;

