- •Vector format when working in 2d and 3d.
- •Spline interpolation
- •Geometric analysis
- •In 2d/3d space. A 2d Delaunay triangulation ensures that the circumcircle
- •Delaunay Triangulation.
- •Voronoi vertices, where numv is the number of vertices and ndim is the
- •Polynomials
- •Vectors of polynomial coefficients, convolving them is equivalent to
Spline interpolation
<spline> - Cubic spline interpolation.
SPLINE Cubic spline data interpolation.
PP = SPLINE(X,Y) provides the piecewise polynomial form of the
cubic spline interpolant to the data values Y at the data sites X,
for use with the evaluator PPVAL and the spline utility UNMKPP.
X must be a vector.
If Y is a vector, then Y(j) is taken as the value to be matched at X(j),
hence Y must be of the same length as X -- see below for an exception
to this.
If Y is a matrix or ND array, then Y(:,...,:,j) is taken as the value to
be matched at X(j), hence the last dimension of Y must equal length(X) --
see below for an exception to this.
YY = SPLINE(X,Y,XX) is the same as YY = PPVAL(SPLINE(X,Y),XX), thus
providing, in YY, the values of the interpolant at XX. For information
regarding the size of YY see PPVAL.
Ordinarily, the not-a-knot end conditions are used. However, if Y contains
two more values than X has entries, then the first and last value in Y are
used as the endslopes for the cubic spline. If Y is a vector, this
means:
f(X) = Y(2:end-1), Df(min(X))=Y(1), Df(max(X))=Y(end).
If Y is a matrix or N-D array with SIZE(Y,N) equal to LENGTH(X)+2, then
f(X(j)) matches the value Y(:,...,:,j+1) for j=1:LENGTH(X), then
Df(min(X)) matches Y(:,:,...:,1) and Df(max(X)) matches Y(:,:,...:,end).
Example:
This generates a sine-like spline curve and samples it over a finer mesh:
x = 0:10; y = sin(x);
xx = 0:.25:10;
yy = spline(x,y,xx);
plot(x,y,'o',xx,yy)
Example:
This illustrates the use of clamped or complete spline interpolation where
end slopes are prescribed. In this example, zero slopes at the ends of an
interpolant to the values of a certain distribution are enforced:
x = -4:4; y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];
cs = spline(x,[0 y 0]);
xx = linspace(-4,4,101);
plot(x,y,'o',xx,ppval(cs,xx),'-');
Class support for inputs x, y, xx:
float: double, single
See also interp1, pchip, ppval, mkpp, unmkpp.
Reference page in Help browser
doc spline
<ppval> - Evaluate piecewise polynomial.
PPVAL Evaluate piecewise polynomial.
V = PPVAL(PP,XX) returns the value, at the entries of XX, of the
piecewise polynomial f contained in PP, as constructed by PCHIP, SPLINE,
INTERP1, or the spline utility MKPP.
V is obtained by replacing each entry of XX by the value of f there.
If f is scalar-valued, then V is of the same size as XX. XX may be ND.
If PP was constructed by PCHIP, SPLINE or MKPP using the orientation of
non-scalar function values specified for those functions, then:
If f is [D1,..,Dr]-valued, and XX is a vector of length N, then V has
size [D1,...,Dr, N], with V(:,...,:,J) the value of f at XX(J).
If f is [D1,..,Dr]-valued, and XX has size [N1,...,Ns], then V has size
[D1,...,Dr, N1,...,Ns], with V(:,...,:, J1,...,Js) the value of f at
XX(J1,...,Js).
If PP was constructed by INTERP1 using the orientation of non-scalar
function values specified for that function, then:
If f is [D1,..,Dr]-valued, and XX is a scalar, then V has size
[D1,...,Dr], with V the value of f at XX.
If f is [D1,..,Dr]-valued, and XX is a vector of length N, then V has
size [N,D1,...,Dr], with V(J,:,...,:) the value of f at XX(J).
If f is [D1,..,Dr]-valued, and XX has size [N1,...,Ns], then V has size
[N1,...,Ns,D1,...,Dr], with V(J1,...,Js,:,...,:) the value of f at
XX(J1,...,Js).
Example:
Compare the results of integrating the function cos and its spline
interpolant:
a = 0; b = 10;
int1 = quad(@cos,a,b);
x = a:b; y = cos(x); pp = spline(x,y);
int2 = quad(@(x)ppval(pp,x),a,b);
int1 provides the integral of the cosine function over the interval [a,b]
while int2 provides the integral, over the same interval, of the piecewise
polynomial pp that approximates the cosine function by interpolating the
computed x,y values.
Class support for input X and the fields of PP:
float: double, single
See also spline, pchip, interp1, mkpp, unmkpp.
Reference page in Help browser
doc ppval