![]() ![]() "NCM", Numerical Computing with MATLAB, has more mathematical details. Now, direct interpolation of your y-values vector with interp1 will mean it will have to be monotonic and unique if that may not be so in the final dataset, then simply redo the fit t'other way 'round I believe it will handle that case with the p-p instead (but I didn't test it). The v5 cubic is the black curve between spline and pchip.Ī extensive collection of tools for curve and surface fitting, by splines and many other functions, is available in the Curve Fitting Toolbox. Here is our example data, modified slightly to exaggerate behavior, and interpgui modified to include the 'v5cubic' option of interp1. Because the abscissa are equally spaced, the v5 cubic can be evaluated quickly by a convolution operation. And remember that extrapolated values are always to be taken with a pinch of salt. The resulting piecewise cubic does not have a continuous second derivative and it does not always preserve shape. interp1 (x,y, 6,7,'linear','extrap') ans. I'll tell you later where the coefficients of the cubics come from. These functions are formed by adding cubic terms that vanish at the end points to the linear interpolatant. We have the y-values at the knots, so in order to get a particular PCHIP, we have to somehow specify the values of the derivative, y', at the knots.Ĭonsider these two cubic polynomials in $x$ on the interval $1 \le x \le 2$. Just as two points determine a linear function, two points and two given slopes determine a cubic. Since we want the function to go through the data points, that is interpolate the data, and since two points determine a line, the plip function is unique.Ī PCHIP, a Piecewise Cubic Hermite Interpolating Polynomial, is any piecewise cubic polynomial that interpolates the given data, AND has specified derivatives at the interpolation points. There is a different linear function between each pair of points. So I added the title plip because this is a graph of the piecewise linear interpolating polynomial. ![]() Alternatively, you can specify a scalar value, in which case, interp1 returns that value for all points outside the domain of x. Set extrapolation to 'extrap' when you want to use the method algorithm for extrapolation. With line type '-o', the MATLAB plot command plots six 'o's at the six data points and draws straight lines between the points. vq interp1(x,v,xq,method,extrapolation) specifies a strategy for evaluating points that lie outside the domain of x. Here is the data that I will use in this post. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |