|
From: Mary on 14 Jun 2005 22:25 Hi, Could anyone tell me whether there is a ready made function in Matlab for natural slpine? Do we have to write a program?
From: John D'Errico on 15 Jun 2005 06:44 In article <ef0aaea.-1(a)webx.raydaftYaTP>, Mary <shi_xinhui2000(a)yahoo.com.cn> wrote: > Could anyone tell me whether there is a ready made function in Matlab > for natural slpine? Do we have to write a program? The logical (one might even say natural) place to look is in the function spline. However spline does not offer a natural spline as an option. Its spline uses what are called "not-a-knot" end conditions, as opposed to the natural end conditions. The natural end conditions for a spline are derived from the origins of splines. If one solves for the deflection of a thin flexible beam that is forced to pass through a set of points in the plane, then (for reasonable deflections) the shape of that beam will be well modeled by a "natural" cubic spline. The name itself derives from the solution of the beam system via the calculus of variations, where for a beam, the appropriate choice of end conditions are the "natural" ones. I.e., the second derivative of the beam deflection at its ends is zero. Said differently, if there is no force at the ends of a beam to bend it, then the beam will have no curvature at the ends. The not-a-knot end conditions are different. They force the spline to be THREE times continuous at the 2nd and next to last knot points, as opposed to the normally twice continuous conditions at most knots of the spline. Is there a difference between these two sets of end conditions? Its often a subtle one, and there is rarely any a priori reason why one would truly prefer the natural end conditions. Just because the natural end conditions are appropriate for a thin beam, why should they be the proper choice for a spline model of some arbitrary system? So, if you really want a C2 interpolating spline for your data, then just use spline, or interp1, which offers spline as one of its options. Having said all that... Often one finds that the basic C2 spline, regardless of end conditions, is not really appropriate for their use. Splines work well as models of thin flexible beams. Shipwrights, carpenters, and draftsmen alike have used the idea for centuries to draw in a smooth curve. Splines don't always work perfectly for modeling that arbitrary set of physical data. For example, one often sees ringing in a spline model when it is forced to go through a transition from a region of high slope into a region where it is constant. Thus even if the data itself is monotone, the spline need not be. While this may be the behavior one might expect in a flexible beam, it is not the behavior one expects from a monotone system. For this reason, one often is better off with a subtle cousin of the spline family - pchip. It might be called a shape preserving interpolant. Pchip will interpolate your data without introducing any extraneous extrema into the curve. I like to call it a locally monotone interpolant. It will produce a monotone result on monotone data. If your data has noise (bumps) in it, then pchip will reproduce the noise, as will any other interpolant. You can find pchip in interp1, or as the function pchip. Pchip does have one cost of its use - it is only a C1 interpolant. This means the second derivative of the pchip function will not be continuous as a traditional spline is. Is this bad? Rarely so. In fact, in most cases you will hardly even see any difference between a C1 and a C2 interpolant. In the rare event where this is a problem, there are also C2 shape preserving interpolants (of many different varieties) available in the literature. Enough already! I see you yawning off to sleep as I've rambled on about the subtleties of interpolation. The feigned snores were a bit too much though. ;-) HTH, John D'Errico -- The best material model of a cat is another, or preferably the same, cat. A. Rosenblueth, Philosophy of Science, 1945
|
Pages: 1 Prev: Need help in image pattern recognition Next: cannot restore segment prot after reloc |