Spline Interpolation with derivative condition for knots

38 Ansichten (letzte 30 Tage)
I have been using "spline" function in MATLAB to generate splines, although it is only possible to enforce derivative conditions at the first and final knot of the spline like this,
x = -4:4;
y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];
cs = spline(x,[0 y 0]);
How can derivative conditions for each knot (x and y) be specified while evaluating the spline?
Any help will be greatly appreciated. :)

Akzeptierte Antwort

John D'Errico
John D'Errico am 29 Apr. 2019
Bearbeitet: John D'Errico am 29 Apr. 2019
Technically, this is impossible to accompish, at least in terms of a cubic spline.
A cubic spline is twice continuously differentiable across the breaks. For n data points, we require the spline to pass through the data points, and be continuous across the breaks, as well as have a continuous derivative, but also to have a continuous second derivative. All of this leaves 2 degrees of freedom, allowing you to choose exactly TWO end conditions to resolve the ambiguity. Typically, the best choice is arguably the not-a-knot end conditions, however, a not uncommon choice is the natural end conditions, thus zero second derivatives at the ends. (That is usally not as good a choice as not-a-knot though.)
However, you want to enfore a spline that passes through n points, as well as specifying the first derivative at each knot? The cost will be that you can no longer enforce second derivative continuity. You will no longer have a spline.
As such, the curve will be less smooth than is a classical spline. There are tools in MATLAB that build interpolants of this general form. For example, pchip is one. A pchip interpolant is not twice differentiable across the breaks. It chooses a set of derivatives at the breask to enforce local monotonicity instead.
So you essentially would have two options. The first is to create an interpolant (like pchip) that is piecewise cubic, but lacks second derivative continuity. Or, you can build a quintic (degree 5) spline, which has sufficient flexibility to allow you to choose the first derivatives, and still be smooth. (In either case, I'd probably use mkpp in the end.)
  4 Kommentare
Pranjal Biswas
Pranjal Biswas am 29 Apr. 2019
Thanks a lot for the extensive explanation, that works for me. Also is there any good resource that you can suggest to read all about diiferent types of curves in literature to get a better understanding.
Pranjal Biswas
Pranjal Biswas am 2 Mai 2019
Bearbeitet: Pranjal Biswas am 2 Mai 2019
Although the toolbox works, I was trying to work without using any external toolboxes. For that case I was thinking of working with quartic splines to impose an extra condition for the slope at the knots as follows,
1) C0 continuity: f1(x) = f2(x)
2) C1 continuity: f1'(x) = f2'(x)
3) C2 continuity: f1''(x) = f2''(x)
4) Slope condition at knot: f1'(x) = a, f2'(x) = a
5) End conditions for f1 and f2
Therefore 5 conditions for each segment of the spline for 5 coefficients. This should result in on a linear system like, Ma=y, thus a=M^(-1)y.
I can code this for a specific number of points, but is there something already which can do this for n points?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by