Spline Toolbox
  Go to function:
    Search    Help Desk 
spap2    Examples   See Also

Least-squares approximation by splines

Syntax

Description

Returns the spline f of order k with knot sequence knots for which

in the weighted mean-square sense, with default weights equal to 1. If the abscissae x satisfy the (Schoenberg-Whitney) conditions

then there is a unique spline (of the given order and knot sequence) satisfying (*) exactly. No spline is returned unless (**) is satisfied for some subsequence of x.

It is also possible to fit to gridded data. If knots is a cell array with m entries, then also x must be a cell array with m entries, as must w be (if given), and k must be an m-vector, and y must be an (m+1)-dimensional array, with y(:,i1,...,im) the datum to be fitted at the m-vector [x{1}(i1),...,x{m}(im)], all i1, ..., im , unless the spline is to be scalar-valued, in which case, in contrast to the univariate case, y is permitted to be an m-dimensional array.

Examples

is the least-squares approximant to the data x, y, by cubic splines with two continuous derivatives, basic interval [a..b], and interior breaks xi, provided xi is a strictly increasing sequence, with entries in (a..b).

As another example, spap2(augknt(x([1 end]),2), 2, x, y); provides the least-squares straight-line fit to data x,y (assuming that x(1)< x(i) < x(end)), while

forces that fit to come very close to the first and last data point.

Algorithm

spcol is called on to provide the almost-block-diagonal collocation matrix (Bj,k(x)), and slvblk solves the linear system (*) in the (weighted) least-squares sense, using a block QR factorization.

Gridded data is fitted tensor-product fashion one variable at a time, taking advantage of the fact that a univariate weighted least-squares fit depends linearly on the values being fitted.

See Also

spapi, slvblk, spcol



[ Previous | Help Desk | Next ]