function func = specex;
% SpecEx
%
% This m-file is part of the material of the lecture
%   Theory and Numerics of Ordinary Differential Equations
% at the Math Department of Halle University, Germany.
% Winter term 2008/09
%
% Author :      Prof. Dr. M. Arnold, martin.arnold@mathematik.uni-halle.de
% Version of :  Oct 27, 2006
%
% Special differential equation, type "exact differential equation"
%
% Reference
%   von Finckenstein et al. II, Section 2, Example (15)
%
% Parameter:
%   none
%
% Example:
%   specex;   %   print -dpng ../png/specex.png

graphwidth  = 14.0;
graphheight = 12.0;
vfac        =  0.95;
vshift      =  0.4;
hfac        =  0.99;
hshift      =  2.0;
papershift  =  0.0;

ActFontSize   = 14;
ActLineWidth  =  2;
ActMarkerSize = 12;
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 ] );

% -> plot data
xmin = -2.0;
xmax =  2.0;
ymin = -2.0;
ymax =  2.0;

x = linspace ( xmin, xmax, 401 );
y = linspace ( ymin, ymax, 401 );
[ XX, YY ] = meshgrid ( x, y );
UU = 0.5*XX.^2 + XX.*YY.^2 - YY;

contour ( XX, YY, UU, -2.0:0.5:4.0   ...
        , 'ShowText',  'on'          ...
        , 'LineWidth', ActLineWidth  ...
        );

axis ( [ xmin xmax ymin ymax ] );

xlabel ( 'x' );
ylabel ( 'y' );
title ( 'Implizite Darstellung der Loesung  u(x,y) = c' );

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

%
% -> Aenderung der Schriftgroesse etc.
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] );
  allch = get ( hf, 'Children' )';
  for hch = allch,
    if strcmp(get(hch,'Type'),'line'),
      set ( hch, 'LineWidth',  ActLineWidth );
      set ( hch, 'MarkerSize', ActMarkerSize );
    end;
  end;
end;

