Using Cubic Spline Interpolation for Yield Curve Points in MATLAB
Summary
The document addresses whether MATLAB’s one-dimensional interpolation function can produce cubic spline interpolations for yield curve data. The response says that the built-in spline method is suitable for interpolating sampled curve values and identifies its boundary convention as not-a-knot end conditions. This means the interpolation uses cubic polynomials locally while imposing a particular smoothness condition at the endpoints.
To apply it, provide the observed coordinates, their corresponding yield values, and the query coordinates where interpolated yields are needed. The answer treats this as a standard interpolation task and does not suggest writing a custom spline routine. Its scope is narrow: it does not compare spline interpolation with other curve-fitting methods, discuss financial shape constraints such as monotonicity or positivity, or explain how interpolation choices affect pricing and risk calculations. The supplied guidance establishes how to invoke the method, but gives no market data example or assessment of fit quality.
Key ideas
- MATLAB’s one-dimensional interpolation function supports cubic spline interpolation through its spline method.
- The method uses not-a-knot endpoint conditions.
- The input consists of observed sample coordinates, corresponding values, and query coordinates.
- The response does not address yield curve constraints or compare spline interpolation with alternative curve-fitting methods.
Tags
Full text
# Cubic spline interpolation function within Matlab # Cubic spline interpolation function within Matlab I want to use the Cubic spline interpolation technique so I can interpolate yield curve points. Now I wonder if I can use the standard matlab function interpl1 (and then using the 'spline' method) or does this yield totally different interpolated points? If this function is not suitable for my purpose where can I can find some code or references to a cubic spline method so I can create a cubic spline function in matlab myself? Thanks. ## Answer by Stefan Voigt (score 1) https://quant.stackexchange.com/a/22828 Why do you think this is not apropriate? Matlabs documentation for 1-D Data interpolation states that interpl1 using method spline is the right way to go: > Spline interpolation using not-a-knot end conditions. The interpolated value at a query point is based on a cubic interpolation of the values at neighboring grid points in each respective dimension. Therefore just use > interp1($x$,$v$,$xq$,'spline'); where Vector $x$ contains the sample points, and $v$ contains the corresponding values, $v(x)$. Vector $xq$ contains the coordinates of the query points.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.