1
votes

I have a 3D grid/surface (I may be using this terminology wrong), i.e. I have data in x, y, and z, for

z = f(x,y)

I want MATLAB to fit a cubic (or other) spline curve to this data, and then I want to extract the actual mathematical spline function, so I can simply write the algebraic function on my own,

z = my_mathematical_spline_curve_function(x,y)

Instead of using the sfit object. I know I can do this with a polynomial curve fit by using MATLAB's fit tool and then extracting the coefficients. I am looking to do the same kind of thing, but I need splines; a polynomial curve doesn't fit the data well enough. Is this possible to do in MATLAB?

1

1 Answers

0
votes

I had a similar question, though in 2d, but the issue remains. Since the spline function is f(t) and not f(x) and t does not map to x (in any easy way I can see at least), the problem is difficult. I have heard of sampling and interpolating those points as the simplest solution (and what I plan on implementing for now), although other's have talked about finding the roots of each piece-wise function to estimate the cubic parameters - though I'm not entirely sure how viable this is. The issue I see with that is that the segments need not actually be functions, so f(x) does not actually 'exist' because t is a scaled measure of segment distance between points, and that is why f(t) works and catmull rom splines for example (the one I'm using) can map circles and shapes.

I may have done a poor job explaining, as I am certainly no expert, but have encountered the problem myself so figured I'd point you to the potential ways of working around it I've seen.

See this thread as well on 2d, though likely equally applicable in 3d: Transform 2d spline function f(t) into f(x)