Postprocessing Splines

You can use the following commands with any example spline, such as the cs, ch and sp examples constructed in the section Cubic Spline Interpolation.

First construct a spline, for example:

sp = spmak(1:6,0:2) 

To display a plot of the spline:


To get the value at a, use the syntax fnval(f,a), for example:


To construct the spline's second derivative:

DDf = fnder(fnder(sp))

An alternative way to construct the second derivative:

DDf = fnder(sp,2);

To obtain the spline's definite integral over an interval [a..b], in this example from 2 to 5:


To compute the difference between two splines, use the form fncmb(sp1,'-',sp2), for example:

Was this topic helpful?