function [ xp, yp ] = interp_spline_data ( xdata, ydata )

%*****************************************************************************80
%
%% interp_spline_data is an interactive spline interpolation program.
%
%  Discussion:
%
%    This function manages an interactive computation which accepts
%    vectors xdata and ydata, constructs a cubic spline interpolant
%    using the 'not-a-knot' end conditions, and returns values of the 
%    spline at 101 sample points.
%
%    The user enters the data vectors xdata and ydata.
%
%    The parameters can be supplied as named variables:
%      xdata = [ 0, 0.25, 0.50, 1.0 ];
%      ydata = [ 1, 0.75, 0,    2.0 ];
%      [xp,yp] = interp_spline_data ( xdata, ydata );
%
%    The parameters can be supplied as two lists of numerical values 
%    and passed to the function:
%      [xp,yp] = interp_spline_data ( [0,0.25,0.50,1.0], [1,0.75,0,2.0] );
%
%    The function can called with no arguments, and they will be requested.
%      [xp,yp] = interp_spline_data();
%      Enter xdata, like [1,1.5,2]: [0,0.25,0.50,1.0]
%      Enter ydata, like [1,2.25,4]: [1,0.75,0,2.0]
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 August 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real xdata(): the x coordinates of the data.
%
%    real ydata(): the y coordinates of the data.
%
%  Output:
%
%    real xp(), yp(): samples of the spline, which can be plotted.
%

%
%  Get xdata, ydata.
%
  if ( nargin < 1 )
    xdata = input ( 'Enter xdata, like [1,1.5,2]: ', 's' );
    xdata = str2num ( xdata );
  elseif ( ischar ( xdata ) )
    xdata = str2num ( xdata );
  end

  if ( nargin < 2 )
    ydata = input ( 'Enter ydata, like [1,2.25,4]: ', 's' );
    ydata = str2num ( ydata );
  elseif ( ischar ( ydata ) )
    ydata = str2num ( ydata );
  end

  cs = spline ( xdata, ydata );

  np = 101;
  xp = linspace ( xdata(1), xdata(end), np );
  yp = ppval ( cs, xp );

  return
end

