Main Content

Introducing Spline Fitting

About Splines inCurve Fitting Toolbox

You can work with splines in Curve Fitting Toolbox™ in several ways.

Using the Curve Fitting app or thefitfunction you can:

  • Fit cubic spline interpolants to curves or surfaces

  • Fit smoothing splines and shape-preserving cubic spline interpolants to curves (but not surfaces)

  • Fit thin-plate splines to surfaces (but not curves)

The toolbox also contains specific splines functions to allow greater control over what you can create. For example, you can use thecsapifunction for cubic spline interpolation. Why would you usecsapiinstead of thefitfunction'cubicinterp'option? You might require greater flexibility to work with splines for the following reasons:

  • You want to combine the results with other splines, e.g., by addition.

  • You want vector-valued splines. You can usecsapiwith scalars, vectors, matrices, and ND-arrays. Thefitfunction only allows scalar-valued splines.

  • You want other types of splines such as ppform, B-form, tensor-product, rational, and stform thin-plate splines.

  • You want to create splines without data.

  • You want to specify breaks, optimize knot placement, and use specialized functions for spline manipulation such as differentiation and integration.

If you require specialized spline functions, see the following sections for an overview of splines, and interactive and programmatic spline fitting.

Spline Overview

曲线拟合工具箱样条函数是用于创建,查看和分析数据的样条近似的工具集合。Splinesare smooth piecewise polynomials that can be used to represent functions over large intervals, where it would be impractical to use a single approximating polynomial.

The spline functionality includes a graphical user interface (GUI) 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:

  • GUIs 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)

Interactive Spline Fitting

You can access all spline functions from thesplinetoolGUI. You can use the GUI to:

  • 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

Seesplinetool.

Programmatic花键配件

以编程方式适合样条曲线,见Spline Constructionfor descriptions of types of splines and numerous examples.