MATLAB Functions | Help Desk |
spline
Cubic spline interpolation
yi = spline(xThe,
y,
xi) pp = spline(x,
y)
spline
function interpolates between data points using cubic spline fits.
yi = spline(x,y,xi)
accepts vectors x
and y
that contain coarsely spaced data, and vector xi
that specifies a new, more finely spaced abscissa. The function uses cubic spline interpolation to find a vector yi
corresponding to xi
.
pp = spline(x,y)
returns the pp
-form of the cubic spline interpolant, for later use with ppval
and other spline functions.
The two vectors
t = 1900:10:1990; p = [ 75.995 91.972 105.711 123.203 131.669 ... 150.697 179.323 203.212 226.505 249.633 ]';represent the census years from 1900 to 1990 and the corresponding United States population in millions of people. The expression
spline(tuses the cubic spline to extrapolate and predict the population in the year 2000. The result is,
p,
2000)
ans = 270.6060The statements
x = 1900:1:2000; y = spline(tinterpolate the data with a cubic spline, evaluate that spline for each year from 1900 to 2000, and plot the result.,
p,
x); plot(t,p,
'o',
x,
y)
spline
is a MATLAB M-file. It uses the M-files ppval
, mkpp
, and unmkpp
. These routines form a small suite of functions for working with piecewise polynomials. spline
uses these functions in a fairly simple fashion to perform cubic spline interpolation. For access to the more advanced features, see the M-files and the Spline Toolbox.
interp1
One-dimensional data interpolation (table lookup)
ppval
Evaluate piecewise polynomial