Introducing Spline Fitting
Spline Overview
The Curve Fitting Toolbox™ spline functions are a collection of tools for creating, viewing, and analyzing spline approximations of data.Splinesare smooth piecewise polynomials that you can use to represent functions over large intervals, where it would be impractical to use a single approximating polynomial.
The spline functionality includes a tool that provides easy access to functions for creating, visualizing, and manipulating splines. The toolbox also contains functions that enable you to evaluate, plot, combine, differentiate, and integrate splines. Because all toolbox functions are implemented in the open MATLAB®language, you can inspect the algorithms, modify the source code, and create your own custom functions.
Key spline features:
Tools that let you create, view, and manipulate splines and manage and compare spline approximations
Functions for advanced spline operations, including differentiation, integration, break/knot manipulation, and optimal knot placement
Support for piecewise polynomial form (ppform) and basis form (B-form) splines
Support for tensor-product splines and rational splines (including NURBS)
在曲线拟合工具箱可以fit splines interactively or programmatically.
Interactive Spline Fitting
Use the Curve Fitter app or the Spline Tool to interactively create spline fits.
Open the Curve Fitter app by enteringcurveFitter
at the MATLAB command line. Alternatively, on theAppstab, in theMath, Statistics and Optimizationgroup, clickCurve Fitter. The Curve Fitter app supports the same spline fitting options as thefit
function.
Open the Spline Tool by enteringsplinetool
at the command line. The Spline Tool supports all spline functions. Use the tool to do the following:
Vary spline parameters and tolerances.
View and modify data, breaks, knots, and weights.
View the error of the spline, or the spline's first or second derivative.
Observe the toolbox commands that generated your spline.
Create and import data, including built-in instructive data sets, and save splines to the workspace.
For more information, seesplinetool
.
Programmatic Spline Fitting
Use thefit
下面的函数:
Fit cubic spline interpolants to curves or surfaces.
Fit smoothing splines and shape-preserving cubic spline interpolants only to curves.
Fit thin-plate splines only to surfaces.
Curve Fitting Toolbox also provides specific splines functions that allow more control and flexibility when you fit splines. For example, use thecsapi
function, instead offit
withfitType
set to"cubicinterp"
, if you want to do one of the following:
Combine the results with other splines, for example, by addition.
Create vector-valued splines. You can use
csapi
with scalars, vectors, matrices, and ND-arrays. Thefit
function supports only scalar-valued splines.Create other types of splines such as ppform, B-form, tensor-product, rational, and stform thin-plate splines.
Create splines without data.
Specify breaks, optimize knot placement, and use specialized functions for spline manipulation such as differentiation and integration.
For more information on how to create splines including B-form, tensor-product, NURBs, and other rational splines, seeSpline Construction.