FUNCTION REFERENCE

csaps

Cubic smoothing spline.

Cubic smoothing spline.

Syntax

pp = csaps(x, y)

Syntax

pp = csaps(x, y, p)

Syntax

values = csaps(x, y, p, xx)

Syntax

[pp, P] = csaps(x, y, p, [], w)

Minimises p*sum(w.*(y - f(x)).^2) + (1-p)*integral(f''(t).^2) over cubic splines with breaks at the data sites: p = 0 gives the weighted least-squares line, p = 1 the natural cubic spline interpolant. With p empty or omitted, p = 1/(1 + trace(R)/(6*trace(Q'*inv(W)*Q))), where R and Q are the tridiagonal and second-divided-difference matrices of the sites; P returns the p used. y may be a matrix with one row per component (pp.dim rows). Unsorted x is sorted, repeated x values are averaged (weights summed) and points with NaN are ignored. The result is the structure mkpp returns (order 4), for ppval and fnval; with xx it is evaluated there. w defaults to ones.

Example

pp = csaps([0 1 2 3 4], [0 1.2 1.8 3.1 4], 0.9); ppval(pp, 2)

Example

[v, P] = csaps(0:4, [0 1.2 1.8 3.1 4], [], [1.5 2.5]); P   % 0.9

Differences from MATLAB: gridded data (x as a cell array) and the roughness weight lambda are not supported yet; zero-weight sites are left out of the breaks.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.