Home > K25104 > Interpolation > cubic_spline_script.m

cubic_spline_script

PURPOSE ^

Usage example for cubic_spline

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 Usage example for cubic_spline
 related to Figure 3.1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Usage example for cubic_spline
0002 % related to Figure 3.1
0003 
0004 x = (-1:0.01:1)';
0005 [~,xn] = size(x);
0006 y = ones(xn)./(ones(xn)+25*x.^2);
0007 plot(x,y,'k')  % plot Runge's example
0008 hold;
0009 n = 8;
0010 inter = 2/n;
0011 nodes = (-1:inter:1)';
0012 values = ones(n+1,1)./(ones(n+1,1)+25*nodes.^2);
0013 a=0; b=0;
0014 [y] = cubic_spline( nodes,values,a,b,x );
0015 plot(x,y)  % plot the interpolant
0016 plot(nodes, values,'o')    % plot the data
0017

Generated on Mon 18-Jan-2016 10:25:49 by m2html © 2005