function profile_spline_test ( )

%*****************************************************************************80
%
%% profile_spline_test() plots the profile data using splines.
%
%  Discussion:
%
%    This program assumes that the file 'profile_nodes.txt' is available.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 August 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Cleve Moler,
%    Numerical Computing with MATLAB,
%    SIAM, 2004,
%    ISBN13: 978-0-898716-60-3,
%    LC: QA297.M625. 
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'profile_spline_test():\n' );
  fprintf ( 1, '  Compute and display a cubic spline interpolant to\n' );
  fprintf ( 1, '  sample data from a facial profile.\n' );
%
%  Read the data.
%
  filename = 'profile_nodes.txt';
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Read (x,y) coordinates from "%s"\n', filename );
  xy = load ( filename );
%
%  Extract xd and yd data vectors.
%
  xd = xy(:,1);
  yd = xy(:,2);
  md = length ( xd );
  fprintf ( 1, '  The data consists of %d (x,y) pairs.\n', md );
%
%  Evaluate the spline through the data.
%
  np = 101;
  xp = linspace ( min ( xd ), max ( xd ), 101 );
  yp = spline ( xd, yd, xp );
%
%  Display the parameterized spline U(T), V(T):
%
  clf ( );
  hold ( 'on' );
    plot ( xp, yp, 'lineWidth', 3 );
    plot ( xd, yd, 'k.', 'markersize', 20 );
  hold ( 'off' );
  axis ( 'equal' );
  grid ( 'on' );
  title ( 'Spline interpolant to profile data', 'fontsize', 16 )

  filename = 'profile_spline_test.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  pause ( 5 );

%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'profile_spline_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
