splin - spline function
Given values fi of a function f at given points xi (fi=f(xi)) this primitive computes a third order spline function S which interpolates the function f. The components of x must be in increasing order. For a periodic spline f(1) must equal f(n); S is defined through the triple (x,f,d) where d=spline(x,f) is the vector of the estimated derivatives of S at xi (fi=S(xi),di=S'(xi)). This function should be used in conjunction with interp.
In the case "periodic" n must be choosen >= 3. In the non periodic case, n must be >= 4 (but n=3 gives some kind of results) and the boundary/end conditions for the spline are of type "not-a-knot conditions" and prescribe (if x1, x2, ..., xn are the interpolation nodes) :
S'''(x2-) = S'''(x2+) S'''(x{n-1}-) = S'''(x{n-1}+)
so the first cubic polynomial p1 is equal to the second p2 and the same is valid for the 2 last ones : p{n-2}=p{n-1}.
x=0:0.5:10;f=sin(x); d=splin(x,f); S=interp(0:0.1:10,x,f,d); plot2d(x',f',-1); plot2d((0:0.1:10)',S',2,'000')