title: Cubic spline interpolation in MATLAB
body: <p>I am using the <code>interp1</code> function in MATLAB to interpolate some missing data in a signal and it works like a charm. However, I would like to know how the function works.</p>
  
  <p>I checked the code of the function <code>interp1</code>, which uses the function <code>spline</code>. The code of the function <code>spline</code> is extremely hard for me to understand, so I have googled and wikipedia'd it, and I know (generally) how it works, with degrees of freedom, and how the function uses polynomials (usually 3rd order) to generate the missing part of the curve.</p>
  
  <p>If I have an array of 20 numbers, and 8 - 12 would be missing (zeros):</p>
  
  <blockquote>
    <p>4 5 2 3 5 4 3 0 0 0 0 0 4 5 2 4 3 5 4 3</p>
  </blockquote>
  
  <p>How does the function determine what numbers would fit in there? Is it a window of a certain width that moves over the data, like processing [1-5], [2-6], [3-7] etc? Or does it use the 2 or 3 numbers to the left and right of the missing data?</p>
  
  <p>I am not looking for a mathematical explanation, I just want to know how it does its magic :)</p>