1

How do you approximate a function for interpolated points? I use the natural cubic spline to interpolate points as follows for n = 500 points:

t=[0; 3; 6; 9]
z=[0; 6; 6; 0]
plot(t,z,'ro')
ti=linspace(0,9,500)

zn = natcubicspline(t,z,ti)
yn = line(ti,zn)

Is there any way approximate a function for these n-many points (for large n)? Or are there ways to treat interpolated points as if they are a function, i.e. find the gradient of the zn vector? Because zn is a vector of constants, this wouldn't necessarily be helpful.

Update: In particular, my data appears to form a 2nd degree polynomial, so I went ahead and used the following Matlab function to fit my data:

p = polyfit(transpose(ti),zn,2)

Which yields coefficient estimates for a 2nd degree polynomial. It does fit the data, but with high error values, and I have to multiply this coefficient vector by a vector [1 z z^2] to get the correct polynomial. Is there any way to streamline this?

kathystehl
  • 831
  • 1
  • 9
  • 26

0 Answers0