| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Spline Toolbox |
| Contents | Index |
| Learn more about Spline Toolbox |
tpaps(x,y)
tpaps(x,y,p)
[...,p] = tpaps(...)
tpaps(x,y) is the stform
of a thin-plate smoothing spline
for the given data sites x(:,j) and
the given data values y(:,j). The x(:,j) must
be distinct points in the plane, the values can be scalars, vectors,
matrices, even ND-arrays, and there must be exactly as many values
as there are sites.
The thin-plate smoothing spline
is the unique minimizer of the
weighted sum
![]()
![]()
![]()
Here, the integral is taken over all of
,
denotes the
sum of squares of all the entries of
, and
denotes the partial derivative
of
with respect to its
th argument,
hence the integrand involves second partial derivatives of
. The smoothing
parameter p is chosen so that (1-p)/p equals
the average of the diagonal entries of the matrix A,
with A + (1-p)/p*eye(n) the coefficient matrix
of the linear system for the n coefficients of
the smoothing spline to be determined. This choice of p is
meant to ensure that we are in between the two extremes, of interpolation
(when p is close to 1 and the
coefficient matrix is essentially A) and complete
smoothing (when p is close to 0 and
the coefficient matrix is essentially a multiple of the identity matrix).
This should serve as a good first guess for p.
tpaps(x,y,p) also inputs the smoothing parameter, p, a number between 0 and 1. As the smoothing parameter varies from 0 to 1, the smoothing spline varies, from the least-squares approximation to the data by a linear polynomial when p is 0, to the thin-plate spline interpolant to the data when p is 1.
[...,p] = tpaps(...) also returns the smoothing parameter actually used.
Example 1. The following code obtains values of a smooth function at 31 randomly chosen sites, adds some random noise to these values, and then uses tpaps to recover the underlying exact smooth values. To illustrate how well tpaps does in this case, the code plots, in addition to the smoothing spline, the exact values (as black balls) as well as each arrow leading from a smoothed value to the corresponding noisy value.
rand('seed',23); nxy = 31;
xy = 2*(rand(2,nxy)-.5); vals = sum(xy.^2);
noisyvals = vals + (rand(size(vals))-.5)/5;
st = tpaps(xy,noisyvals); fnplt(st), hold on
avals = fnval(st,xy);
plot3(xy(1,:),xy(2,:),vals,'wo','markerfacecolor','k')
quiver3(xy(1,:),xy(2,:),avals,zeros(1,nxy),zeros(1,nxy), ...
noisyvals-avals,'r'), hold off

Example 2. The following code
uses an interpolating thin-plate spline to vector-valued
data values to construct a map, from the plane to the plane, that
carries the unit square
pretty much onto the unit disk
, as shown by
the picture generated.
n = 64; t = linspace(0,2*pi,n+1); t(end) = []; values = [cos(t); sin(t)]; centers = values./repmat(max(abs(values)),2,1); st = tpaps(centers, values, 1); fnplt(st), axis equal
Note the choice of 1 for the smoothing parameter here, to obtain interpolation.

The determination of the smoothing spline involves the solution of a linear system with as many unknowns as there are data points. Since the matrix of this linear system is full, the solving can take a long time even if, as is the case here, an iterative scheme is used when there are more than 728 data points. The convergence speed of that iteration is strongly influenced by p, and is slower the larger p is. So, for large problems, use interpolation, i.e., p equal to 1, only if you can afford the time.
![]() | titanium | Glossary | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |