%% Evaluate Functions at Specified Points
% This example shows how to interpolate some data and plot and evaluate the resulting functions.
% Define some data.

x = [0.074 0.31 0.38 0.53 0.57 0.58 0.59 0.61 0.61 0.65 0.71 0.81 0.97];
y = [0.91 0.96 0.77 0.5 0.5 0.51 0.51 0.53 0.53 0.57 0.62 0.61 0.31]; 

% Interpolate the data and plot the resulting function, f.

f = csapi( x, y )
fnplt( f )

% Find the value of the function f at x = 0.5.

fnval( f, 0.5 )

% Find the value of the function f at 0, 0.1, ..., 1.

fnval( f, 0:0.1:1 )

% Create a function f2 that represents a surface.

x = 0.0001+(-4:0.2:4);
y = -3:0.2:3;
[yy, xx] = meshgrid( y, x );
r = pi*sqrt( xx.^2+yy.^2 );
z = sin( r )./r;
f2 = csapi( {x,y}, z ); 

% Plot the function f2.

fnplt( f2 )
axis( [-5, 5, -5, 5, -0.5, 1] );

% Find the value of the function f2 at x = -2 and y = 3.

fnval( f2, [-2; 3] )

%
% Copyright 2019 The MathWorks, Inc.