Main Content

Selecting an Interpolant Fit

Selecting an Interpolant Fit Interactively

In the Curve Fitting app, selectInterpolantfrom the model type list.

TheInterpolantfit category fits an interpolating curve or surface that passes through every data point. For surfaces, the Interpolant fit type uses the MATLAB®散落的人function for linear and nearest methods, the MATLABgriddatafunction for cubic and biharmonic methods, and thetpapsfunction for thin-plate spline interpolation.

设置在此处显示。

You can specify theMethodsetting:Nearest neighbor,Linear,Cubic,Shape-preserving (PCHIP)(for curves),Biharmonic (v4)(for surfaces) orThin-plate spline(for surfaces). For details, seeAbout Interpolation Methods.

Tip

If you are fitting a surface and your input variables have different scales, turn theCenter and scaleoption on and off to see the difference in the surface fit. Normalizing the inputs can strongly influence the results of the triangle-based (i.e., piecewiseLinearCubicinterpolation) andNearest neighborsurface interpolation methods.

For surfaces, try thin-plate splines when you require both smooth surface interpolation and good extrapolation properties.

Fit Linear Interpolant Models Using thefitFunction

This example shows how to use thefitfunction to fit linear interpolant models to data.

Interpolant Fitting Methods

Specify the interpolant model method when calling thefitfunction using one of the options outlined inInterpolant Model Names. None of the interpolant methods has any additional fit option parameters.

Fit a Linear Interpolant Model

加载数据并使用线性插值模型使用'linearinterp'选项。

loadcensusf = fit(cdate,pop,'linearinterp'); plot(f,cdate,pop);

Figure contains an axes object. The axes object contains 2 objects of type line. These objects represent data, fitted curve.

Compare Linear Interpolant Models

加载数据,并使用该数据创建最近的邻居和Pchip interpolant Fits使用'nearestinterp'“pchip”options.

loadcarbon12alphaf1 = fit(angle,counts,'nearestinterp'); f2 = fit(angle,counts,“pchip”);

比较合适的曲线f1f2上a plot.

p1 = plot(f1,angle,counts); xlim([min(angle),max(angle)]) holdp2 =图(f2,'b'); holdofflegend([p1;p2],'Counts per Angle','Nearest Neighbor',“pchip”,...'地点','northwest')

Figure contains an axes object. The axes object contains 3 objects of type line. These objects represent Counts per Angle, Nearest Neighbor, pchip.

对于“ CupicInterp”或“ Pchipinterp”的替代方案,您可以使用其他样条函数,使您可以更好地控制自己创建的内容。看About Splines in Curve Fitting Toolbox.

看Also

相关话题