If you try performing linear interpolation in matlab, it uses a "gridded" interpolant apparently.
Normally, I would expect the linear interpolation function to look something like this:
METHOD A:
Where we wish to know the value of y(u) at u.
However, matlab seems to use the formulas below:
METHOD B:
So the result ends up actually being different if you use method A and compare the answer to method B. The difference in the result I found to be around 2^-18 in double precision floating point arithmetic for certain inputs.
My Question:
Why does MATLAB choose to use Method B? It appears method A would involve less calculations. Also, is either formula "more" correct?
Performing method A should involve the following:
temp = (y(k+1)-y(k))/(x(k+1)-x(k))
y(u) = y1 + temp*(u-x(k))